Comments (8)
One thing I didn't want to enforce is a naming convention for migrations (the prefix). You can use the epoch, some kind of formatted time stamp or a sequence number; you can separate it using dashes or underscores: all these options are perfectly fine and valid, it's just a choice you make for your project.
I'd love to have a new
command, but we'll need to find a way to avoid pushing people into a fixed pattern.
If we can figure that out: yes please!
from sql-migrate.
OK so how about we have a way of specifying the format in the config or use the default? Options could be
epoch
- defaultiso
for ISO-8601 datestampcounter
which increments count of current folder listingnone
Also I would like to append the action
so to expand on my example above:
sql-migrate new udf-ParseDate alter
results in ./migrations/1443610373-udf-ParseDate-alter.sql
If action is create
then the pre-population of the migrate Down
would be skipped, but for alter
or drop
it can do the scanning thing and populate it.
from sql-migrate.
If action is create then the pre-population of the migrate Down would be skipped, but for alter or drop it can do the scanning thing and populate it.
How would that work?
OK so how about we have a way of specifying the format in the config or use the default?
Can we be smart about it and detect the used style from existing migration files?
from sql-migrate.
How would that work?
As an outline, it would:
- use the
name
and find all the migrations that match in the filename. - establish the latest one
- which should be sort filename descending, take the first.
- If
none
was chosen that might be tricky or unreliable as it would have to rely upon modified date.
- Read that file, find the
-- +migrate Down
- Insert into template
Can we be smart about it and detect the used style from existing migration files?
We could do, so look at the first & last file and use regex to work out the format. Personally I'd rather use the config file rather than trying to be smart (KISS principle). At the end of the day, this would only affect the new
command usage.
from sql-migrate.
Personally I'd rather use the config file rather than trying to be smart (KISS principle).
I guess we have different opinions on KISS then :-). Any piece of configuration we can avoid is a net win, but if the alternative is something that barely works, sure.
from sql-migrate.
One thing I didn't want to enforce is a naming convention for migrations (the prefix). You can use the epoch, some kind of formatted time stamp or a sequence number; you can separate it using dashes or underscores: all these options are perfectly fine and valid, it's just a choice you make for your project.
Is it bad to use a default prefix if you allow them to change the prefix-pattern in the config? I personally have always used the YYYY-MM-DD-HH-II-SS pattern but a sequence number or epoch would work just as good. Personally I would not think it's bad to choose a default and then just let the config decide.
Do you feel that you are enforcing them when choosing a default that can be changed in the config?
from sql-migrate.
I'd find this quite useful. I'd also make sense because incrementing the prefix by hand doesn't work in big teams where people create migrations simultanously and creating a timestamp by hand just feels weird. Many modern migration cli tools offer a create
sub command. Good idea!
from sql-migrate.
Thanks to the wonderful work of @yageek, there's now a new
command.
It's not configurable nor smart, but we had to start somewhere. If someone is willing to make this format configurable and/or smart, feel free to join in!
from sql-migrate.
Related Issues (20)
- Migration not applied
- 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
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.