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

Support creating a table migration generator #8652

Merged
merged 1 commit into from Mar 1, 2013

Conversation

@codeodor
Copy link
Contributor

@codeodor codeodor commented Dec 29, 2012

Sometimes you want to create a table without an associated model and test, which is also not a join table. With this commit, you can now do that.

I've typed these commands enough times over the years and ended up with empty migrations that I finally decided to add them to Rails and see if anyone else considered it useful.

Example:

rails g migration create_posts title:string

or

rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the migration to the migration templates folder, as it seems a more sensible place for it now that it is shared code.

@steveklabnik
steveklabnik reviewed Feb 25, 2013
View changes
activerecord/CHANGELOG.md Outdated
@@ -1204,4 +1204,15 @@

*Aaron Patterson*

* Added support for creating a table via Rails migration generator.

This comment has been minimized.

@steveklabnik

steveklabnik Feb 25, 2013
Member

This needs to be moved to the top.

@steveklabnik
Copy link
Member

@steveklabnik steveklabnik commented Feb 25, 2013

I like it. 👍

@codeodor
Copy link
Contributor Author

@codeodor codeodor commented Feb 25, 2013

Thanks Steve. When you say "this needs to be moved to the top," what are you referring to? That I need to move the changelog entry to the top of the file instead of the bottom of the file?

Sam

@robin850
Copy link
Member

@robin850 robin850 commented Feb 25, 2013

Seems good. I'm 👍 on this!

I allow myself to answer your question : yes, you should move your changelog entry to the top of the file.

Thanks for your contribution! :)

@steveklabnik
Copy link
Member

@steveklabnik steveklabnik commented Feb 25, 2013

Yes, I mean it should be at the top of the file.

end

protected
attr_reader :migration_action, :join_tables

def set_local_assigns!
@migration_template = "migration.rb"

This comment has been minimized.

@rafaelfranca

rafaelfranca Feb 25, 2013
Member

This file don't exist anymore since you moved to create_table_migration

This comment has been minimized.

@codeodor

codeodor Feb 25, 2013
Author Contributor

This file still exists and is the default file for taking care of the other migrations. See Line 30-32 where it uses create_table_migration.rb for migrations which create tables.

Do you have any suggestion for how I can improve the code to make this more obvious/clear?

This comment has been minimized.

@rafaelfranca

rafaelfranca Feb 25, 2013
Member

The code is obvious the problem was github with the misleading information that the file was renamed.

Screen Shot 2013-02-25 at 10 45 55

Sorry

This comment has been minimized.

@codeodor

codeodor Feb 25, 2013
Author Contributor

Thanks for letting me know. I'll try to be more clear next time. For what it's worth, the file did get moved: it used to live with the model generator, while now it is with the migration generator.

@codeodor
Copy link
Contributor Author

@codeodor codeodor commented Feb 25, 2013

Ok, I moved the changelog entry to the top of the file.

Any other feedback? (for example, should I pull from rails/master and merge?)

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Feb 25, 2013

Could you squash the commits and rebase against master? It cannot be automatically merged

@codeodor
Copy link
Contributor Author

@codeodor codeodor commented Feb 25, 2013

Ok, I rebased onto master, and the PR contains one commit. How does it look now?

@milushov
Copy link

@milushov milushov commented Mar 1, 2013

👍 👍 👍

@carlosantoniodasilva
Copy link
Member

@carlosantoniodasilva carlosantoniodasilva commented Mar 1, 2013

Looks good 👍. But github says it cannot be automatically merged, can you please rebase again? (it's likely a changelog conflict).

Sometimes you want to create a table without an associated model and
test, which is also not a join table. With this commit, you can now
do that.

Example:

    rails g migration create_posts title:string
or
    rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the
migration to the migration templates folder, as it seems a more
sensible place for it now that it is shared code.
@codeodor
Copy link
Contributor Author

@codeodor codeodor commented Mar 1, 2013

Ok, done. Does it say it will merge cleanly?

@carlosantoniodasilva
Copy link
Member

@carlosantoniodasilva carlosantoniodasilva commented Mar 1, 2013

Yup it does. Thank you!

carlosantoniodasilva added a commit that referenced this pull request Mar 1, 2013
Support creating a table migration generator

Sometimes you want to create a table without an associated model and
test, which is also not a join table. With this commit, you can now
do that.

Example:

    rails g migration create_posts title:string
or
    rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the
migration to the migration templates folder, as it seems a more
sensible place for it now that it is shared code.
@carlosantoniodasilva carlosantoniodasilva merged commit b49a2a7 into rails:master Mar 1, 2013
@codeodor
Copy link
Contributor Author

@codeodor codeodor commented Mar 1, 2013

Awesome, thanks! 👍 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.