Skip to content

createTable should allow close to copy paste from Model definition #5213

Description

@mickhansen

Including:

  • Constraints
  • Indexes

Activity

  1. added
    type: feature
    on Jan 13, 2016
  2. added this to the 4.0 milestone on Jan 13, 2016
  3. changed the title [-]createTable should allow copy paste from Model definition[/-] [+]createTable should allow close to copy paste from Model definition[/+] on Jan 13, 2016
  4. manuelbieh commented on Jan 21, 2016

    @manuelbieh

    I have written a "migration schema generator" which uses models a few days ago. Works fine with several dataTypes (STRING, TEXT, INTEGER, BOOLEAN, ENUM, DATETIME) and since I'm using the SET FOREIGN_KEY_CHECK = 0 workaround even foreign key constraints are working.

    My last problem (and I haven't found a solution yet) are indexes because I just haven't found the index definition anywhere in the model. Maybe you can help? models[model].indexes is undefined :(

    The generator:
    https://gist.github.com/manuelbieh/ae3b028286db10770c81

  5. manuelbieh commented on Jan 21, 2016

    @manuelbieh

    Ok, I have just found them in models[model].options.indexes :)

    Maybe you want consider to offer an official "migration file generator" instead of changing the createTable interface? (Just an idea)

    A really awesome feature would be if you could compare two models and create a diff file to use with db:migrate - so you can automatically create a new migrationfile by comparing an old and a new model!

  6. mickhansen commented on Jan 21, 2016

    @mickhansen
    ContributorAuthor

    What you suggest is something we'd like to do.
    We'd like to be able to diff a model against a database and generate a structure that can be formatted into a migration or a query or whatever.
    Diffing between two models could work off that, the question is how you show the two models at the same time though (git?)

  7. manuelbieh commented on Jan 21, 2016

    @manuelbieh

    Good point. Diffing against a database makes more sense 👍

  8. modified the milestones: , 4.0 on Jun 8, 2017
  9. stale commented on Aug 12, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

  10. modified the milestones: v5, v6 on Mar 13, 2019
  11. added
    breaking change
    on Aug 1, 2019
  12. removed this from the v6 milestone on Jun 24, 2020
  13. added theissue type on Mar 9, 2025
  14. removed
    type: feature
    on Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions