Skip to content

Handle database migrations #359

Closed
Closed

Description

@afilini

Description

We could store a "database structure serial" in the db and check it every time it's loaded, to detect when the structure changes.

A good example of how database migrations can be done is in the database/sqlite module. The goal of this issue is to add general support for any database module to update to a new structure when required.

Expected Outcomes

  • Create a new trait and possibly structs in the database module to support database schema migration
  • Implement or update database migration for the keyvalue and sqlite modules
  • Any new public traits and structs should be documented
  • New trait implementations should have basic unit tests
  • Error if database schema version is > version in code (ie. using older code on database migrated with newer version)

Resources

Skills Required

  • Experience with git. Guide
  • Basic familiarity with rust. First seven chapters of the book
  • Basic familiarity with SQL and JSON
  • Familiarity with BDK’s keyvalue and sqlite database modules

Mentor(s)
@notmandatory

Difficulty
Medium

Competency Test

  • Install rust, compile and run all bdk examples and tests.
  • Read through the BDK docs.
  • Make a dummy wallet with BDK with key-value and sqlite backends.
  • Familiarity with basic rust, should be able to write basic custom trait implementations on foreign structures.

Activity

  1. notmandatory commented on Sep 21, 2021

    @notmandatory
    Contributor

    DB schema migration/upgrades are being done in #376 but only for the sqlite Database. Could we handle this as a Database specific feature? in that case we'd only need to add it as an internal part of the key-value DB.

  2. LLFourn commented on Sep 24, 2021

    @LLFourn
    Collaborator

    ^ can we add some kind of "transparently handle db upgrade architecture" task to upcoming hackathon?

  3. added
    summer-of-bitcoin
    on Dec 15, 2021
  4. notmandatory commented on Dec 16, 2021

    @notmandatory
    Contributor

    Per our team chat yesterday I changed this into a summer-of-bitcoin project.

  5. self-assigned this
    on Feb 14, 2022
  6. LLFourn commented on Jan 22, 2024

    @LLFourn
    Collaborator

    We don't have a Database trait anymore so this issue is stale. We could allow people to migrate from one persistence backend to another generically -- this would be pretty easy now. But that feels like another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

module-databasenew featuresummer-of-bitcoin

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions