Giter Club home page Giter Club logo

mg's People

Contributors

hkalexling avatar kalafut avatar nicolab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kalafut

mg's Issues

Feature request: Lifecycle

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

conn.exec query

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 ๐Ÿ™‚

How to migrate 2 databases

Hi

I have 2 sqlite3 databases - can this tool support migrating each of them? when I tried it gets confused saying duplicate versions found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.