Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DB Versioning #251

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dezren39
Copy link
Contributor

@dezren39 dezren39 commented Jan 5, 2024

Hello

So I added a few features to the migration within charm so that I could feel safe using and merging code while also adding my own migrations. I've attempted to make a 'clean' pr that you could potentially use. I've confirmed this 'builds' and I confirmed my fork works ok, but I didn't 'battle-test' this exact branch. One specific thing I didn't test, I tried to revert my changes to allow libsql driver #250, I didn't test this. if you merge #250 or this pr, the other may need updates. Additionally, I assume you have an existing charm database, you may want to make a patch to add the version table and existing migrations already, although all the current migrations seem to be very safe, (if not exists type of things).

I know this may not be exactly the direction you want to take your tool, so please do close this or suggest any changes you would like. In my other projects I'm using goose, but you had rolled your own so I added to the existing structure. I believe this wouldn't be needed with minimal changes or only changes that are additions/mostly complementary. This is a start towards some safeguards I've become used to from using dedicated tools for these type of things.

  • validate incremental versions in code, starting from 1 until end
  • insert version, run transaction which completes version, if err then insert err into table
  • check version on boot, if no version table, init db, else note if migration is possible or incomplete version exists then error
  • make initial create tables a migration like other migrations (increment fk migration from 1 to 2)
  • init db and serve migrate now use same 'migrate' function
  • log.Print -> log.Info, started using log.Error

is there a way to enable debug mode within charm serve? charm_debug or charm_serve_debug or something? or charm(_serve)(_log)_level?

* add versions

* align
@dezren39 dezren39 changed the title Add DB Versioning (#1) Add DB Versioning Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant