Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
mickhansen opened this issue Jan 13, 2016 · 5 comments
Open
2 tasks

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

mickhansen opened this issue Jan 13, 2016 · 5 comments
Labels
breaking change For issues and PRs. Changes that break compatibility and require a major version increment. type: feature For issues and PRs. For new features. Never breaking changes.

Comments

@mickhansen
Copy link
Contributor

Including:

  • Constraints
  • Indexes
@mickhansen mickhansen added the type: feature For issues and PRs. For new features. Never breaking changes. label Jan 13, 2016
@mickhansen mickhansen added this to the 4.0 milestone Jan 13, 2016
@mickhansen mickhansen changed the title createTable should allow copy paste from Model definition createTable should allow close to copy paste from Model definition Jan 13, 2016
@manuelbieh
Copy link

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

@manuelbieh
Copy link

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!

@mickhansen
Copy link
Contributor Author

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?)

@manuelbieh
Copy link

Good point. Diffing against a database makes more sense 👍

@sushantdhiman sushantdhiman modified the milestones: 5.0, 4.0 Jun 8, 2017
@stale stale bot added the stale label Aug 12, 2017
@stale
Copy link

stale bot commented Aug 12, 2017

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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change For issues and PRs. Changes that break compatibility and require a major version increment. type: feature For issues and PRs. For new features. Never breaking changes.
Projects
None yet
Development

No branches or pull requests

5 participants