Giter VIP home page Giter VIP logo

Comments (4)

dhui avatar dhui commented on May 18, 2024 4

I'm not convinced of the value of migrate creating the DB is worth the cost but think this is an issue worth discussing.

I see the following issues with migrate creating the DB:

  1. Compatibility with other DB drivers. For consistency, every driver would also need to implement a similar setup and the referenced PR only implements the change for MySQL.
  2. What is the expected state of the DB for the first migration and what role does migrate play? Currently, migrate doesn't change the state of the DB so the first migration starts w/ a "clean slate" and any necessary DB configuration is done out of band.
  3. Elevated permissions - Generally creating DBs and Tables require different permission levels

The value I see is:

  1. Makes setting up a DB environment slightly easier
    • There are better tools like docker and terraform to do this for you

from migrate.

thurt avatar thurt commented on May 18, 2024 2

Thanks for your thoughts! The permissions point is something I hadn't thought about much as I am accustomed to thinking about access control defined by the application rather than in the database.

I think it's just an easier development process to have db schema changes (including db creation) organized around one tool. But I do see the fine line here about db creation being out of scope for migrate.

Currently, I create a database with a Dockerfile which just has a single COPY instruction to move /docker-entrypoint-initdb.d/createDatabase.sql into the mysql base image (see header Initializing a fresh instance). That is not as nice as just being able to always use the base mysql image and drive the schema changes in code with a tool like migrate.

from migrate.

murphybytes avatar murphybytes commented on May 18, 2024

I'd be interested in having this feature for postgres as well. The reason is mig.Drop doesn't work for databases that have functions, triggers and the like. It only drops the tables and if you have interdependencies in your database code. It doesn't work. This makes it impossible to perform unit tests starting with a clean slate base for every unit test. With postgres, I've been forced to execute a query killing all open connections before the test, drop the test table if it exists, and then re-create it.

from migrate.

dhui avatar dhui commented on May 18, 2024

@murphybytes Do your up migrations which add the functions and triggers have corresponding down migrations which drop the functions and triggers?

from migrate.

Related Issues (20)

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.