Feature: Migrations
See original GitHub issueJust like replace is doing it for Data, we could add an utility function which looks at first if a table exists, if not create it, and if the table exists also checks if fields|columns are missing, adds them in a non-destructive fashion.
I’ve already made an Table Creator that i could PR(if wanted)
Ex.:
checkTableExists('session').then(...).catch(() => {
createTable("session", [
new BaseField('id').isUnique().setType("VARCHAR(256)"),
new BaseField('created_at').setType('BIGNUMBER')
])
})
It doesn’t yet support checking for fields missing. Though creating a table would be a useful addition i think.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Database Migrations | FeatureFlags
Use feature flags to safely migrate or update databases. There comes a time in every developer's life when you realize you need to...
Read more >Database Migrations with Feature Flags - Split Software
In this post, we are talking about database migrations in the context of updating schemas ... Use Feature Flags to Migrate Your Schemas....
Read more >Using feature flags to mitigate risk in infrastructure migrations
This guide explains how you can use feature flags to mitigate risks associated with infrastructure migrations.
Read more >Feature toggles and database migrations (Part 3)
Part 3 of this series focusses specifically on using toggles when migrating databases.
Read more >Migrations Overview - EF Core | Microsoft Learn
The migrations feature in EF Core provides a way to incrementally update the database schema to keep it in sync with the application's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome! I’m very glad you like it!
That’s a pretty easy thing to fix. And the tests will fail anyway since we have a special test case for this. So, everything is good.
https://github.com/rahmanfadhil/cotton/blob/5828520c05d5fe4edbe717cceca3e4df4f82f174/src/migrations/migration_test.ts#L5-L13
I’m not sure if anyone needs to export/import their database programmatically. Maybe we can provide a CLI for it? 🤔
Anyway, I’m really excited to have some kind of database seeder and factory to populate the database with realistic dummy data for development and testing purposes.
Lastly, I’m going to remove the old migration code in
src/table.ts
, because everything is already moved tosrc/migrations
.I will keep this issue open until this feature is released and merged into the
master
branch. So, if you have any ideas or suggestions, I’m more than happy to discuss about it. Thanks!This feature is now merged with master 🎉
Checkout the docs for more info.