hkalexling / mg Goto Github PK
View Code? Open in Web Editor NEWA minimal database migration tool for Crystal
Home Page: https://hkalexling.github.io/mg/
License: MIT License
A minimal database migration tool for Crystal
Home Page: https://hkalexling.github.io/mg/
License: MIT License
Hi
after_up and after_down don't seem to be executed when calling migrate. My puts statements there did not show up.
Hello,
Using Tags
annotation with Posgres causes this SQL error:
STATEMENT: PRAGMA user_version
ERROR: syntax error at or near "PRAGMA" at character 1
Caused by https://github.com/hkalexling/mg/blob/master/src/mg/migration.cr#L83
Because PRAGMA is SQLite specific.
@[MG::Tags("db1")]
class CreateTables < MG::Base
When I remove Tags
, the migrations are ok but the error is always here.
What is the use of Tags annotation?
Hello,
Thanks for this useful shards. The fact of managing migrations in Crystal code instead of raw SQL files allows some possibilities (available with migration libs in other languages, but non-existent in Crystal).
Unless I am mistaken, MG only allows to do actions before the migration and at the end of all migrations of course (after mg.migrate
).
In the idea to be able to program actions during migrations, it would be interesting to have (optional) lifecycle methods in each class.
Example:
def up : String
puts "before up. Actually it's already possible"
<<-SQL
# SQL statements....
SQL
end
def up_done
puts "after up is done"
end
def down : String
puts "before down. Actually it's already possible"
<<-SQL
# SQL statements....
SQL
end
def down_done
puts "after down is done"
end
This can be useful to perform data conversions (due to a new DB structure by example), clean cache, ... Example for migrating entries linked by foreign keys, useful for the next migration.
Just a suggestion, this can be implemented by adding empty methods (example: up_done
and down_done
) in MG::Base
. Then call them after exec query
Line 138 in 5320c19
What do you think?
Also, I have another question by the way. Is it an occasional shard (no particular need for you) or are you planning to maintain it for a long time?
This (curious) question because I want to add MG here https://github.com/Nicolab/crystal-dbx/blob/master/guide/migration.md (DBX docs) as well as use it by default in a framework that I will release soon ๐
Hi
I have 2 sqlite3 databases - can this tool support migrating each of them? when I tried it gets confused saying duplicate versions found.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.