Comments (8)
Definitely option 1. If there is any issue whatsoever, don't try to forge on--maintain data integrity and make it the user's fault if something goes wrong. If a database is at an unknown migration, that means the client is probably outdated.
from sql-migrate.
I tend to agree here with @20zinnm: you don't want to silently cover up things that go wrong. They'll come back to bite you later on when they're much harder to diagnose.
from sql-migrate.
Resurrecting a slightly older issue here but I have the same problem as described by @ericklaus-wf . In particular, when the last applied migration in the database is "unknown" then the tool would not apply any new migrations and happily tell you everything is alright. You would be non the wiser if you do not check with status
. This is related to #85 as well since this is the culprit code.
Think I would be able to implement option 1 described here. My proposal is this: whenever an "unknown" migration is found, then PlanMigration
would return an error. This way it would work no matter whether you are using the sql-migrate
binary or using this repo as a library as I do. What do you think about it?
from sql-migrate.
Done, I've created a pull request which implements option 1. I think it worked out great.
from sql-migrate.
Fix is merged thanks to @ironsmile!
from sql-migrate.
Hi all,
First of all, thank you for the tool. Its alleviating the anxiety I typically experience with migrations π―
I've encountered the issue above and it seems the resolution to option 1 was to return an error however there does not seem to be a force flag available as was suggested?
Here's my situation, maybe someone can offer 2c on an alternative solution:
My use case is that we are splitting up our Go codebase into modular, re-usable services. Eventually they will be deployed separately, however in the mean time we are currently still merging them into one monolithic binary.
Here's a simplified version of our codebase:
|
|--> serviceA --> migrations/ --> 0000_initial_a.sql
|--> serviceB --> migrations/ --> 0000_initial_b.sql, 0001_adjustment.sql, etc
Service B depends on Service A. I wrote an inhouse migration tool which uses packr to embed the migrations of each service and then perform them in sequence. Eventually this will not be required since Service A's deployment will be independent of Service B, but for the time being they are performed on the same DB.
ServiceB's migrations succeed however when it comes to serviceA's migrations I am on the receiving end of the unknown migration in database
error.
Thanks for your time, any tips appreciated!
from sql-migrate.
Hi @simonamdev, my use case is the same as your use case. Have you had any tips yet?
from sql-migrate.
Hi all,
First of all, thank you for the tool. Its alleviating the anxiety I typically experience with migrations π―
I've encountered the issue above and it seems the resolution to option 1 was to return an error however there does not seem to be a force flag available as was suggested?
Here's my situation, maybe someone can offer 2c on an alternative solution:
My use case is that we are splitting up our Go codebase into modular, re-usable services. Eventually they will be deployed separately, however in the mean time we are currently still merging them into one monolithic binary.
Here's a simplified version of our codebase: | |--> serviceA --> migrations/ --> 0000_initial_a.sql |--> serviceB --> migrations/ --> 0000_initial_b.sql, 0001_adjustment.sql, etc
Service B depends on Service A. I wrote an inhouse migration tool which uses packr to embed the migrations of each service and then perform them in sequence. Eventually this will not be required since Service A's deployment will be independent of Service B, but for the time being they are performed on the same DB.
ServiceB's migrations succeed however when it comes to serviceA's migrations I am on the receiving end of the
unknown migration in database
error.Thanks for your time, any tips appreciated!
After reading the source code, I found that we could use the different migration table name for each service instead of using the default one gorp_migrations
. You can use SetTable
function to set the name of the table used to store migration info for each service. For example:
migrate.SetTable("service_a_gorp_migrations") // for your ServiceA
and
migrate.SetTable("service_b_gorp_migrations") // for your ServiceA
That is the way I fixed my problem. Thank you.
from sql-migrate.
Related Issues (20)
- IgnoreUnknown is not working
- SetTable fails race detector HOT 3
- Support for multiple migration dirs
- Where may I ask questions? HOT 2
- gorp retracted by module author warning HOT 2
- Support for exclusive connection while executing migration HOT 3
- ToApply doesn't consider IgnoreUnknown flags when apply migrations up dir HOT 1
- Multiple `migrate Up` blocks in a single file? HOT 1
- Migrate transactions for multiple shards HOT 5
- [Proposal] Addition of 'reset' to sql-migrate command HOT 3
- Go install fails on Go 1.19 HOT 5
- schema field in dbconfig.yml being ignored
- Doing a migrate down when there is a migration βholeβ is corrupting the database
- MemoryMigrationSource execution order is wrong HOT 2
- [BUG] Missing integrity checks on migrations lead to corrupt DB schema state HOT 3
- Logic Bug with ExecVersion HOT 1
- Possible release to fix build issue on Alpine Linux HOT 1
- Migration failed: pq: unterminated dollar-quoted string at or near HOT 1
- sql-migrate in docker registry
- How to distinguish the different branches HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sql-migrate.