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 for foreign keys in create table #20009

Merged
merged 1 commit into from Sep 20, 2015

Conversation

Projects
None yet
5 participants
@kamipo
Member

kamipo commented May 4, 2015

If foreign keys specified in create table, generated SQL is slightly more efficient.

Definition:

create_table :testings do |t|
  t.references :testing_parent, foreign_key: true
end

Before:

CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer);
ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id");

After:

CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"));
@mrageh

This comment has been minimized.

Show comment
Hide comment
@mrageh

mrageh Jun 1, 2015

Contributor

Could you add tests for this change?

Contributor

mrageh commented Jun 1, 2015

Could you add tests for this change?

@kamipo

This comment has been minimized.

Show comment
Hide comment
@kamipo

kamipo Jun 13, 2015

Member

I added tests for this change, thanks!

Member

kamipo commented Jun 13, 2015

I added tests for this change, thanks!

@mrageh

This comment has been minimized.

Show comment
Hide comment
@mrageh

mrageh Jun 15, 2015

Contributor

Looks good 👍
@senny and @rafaelfranca this pr looks good, do we want to merge it or should it be rebased first before it's merged?

Contributor

mrageh commented Jun 15, 2015

Looks good 👍
@senny and @rafaelfranca this pr looks good, do we want to merge it or should it be rebased first before it's merged?

@kamipo

This comment has been minimized.

Show comment
Hide comment
@kamipo

kamipo Sep 16, 2015

Member

r? @senny
Could you review this change?

Member

kamipo commented Sep 16, 2015

r? @senny
Could you review this change?

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Sep 19, 2015

Member

Nice improvement, @kamipo. Could you rebase against the recent changes?

Member

jeremy commented Sep 19, 2015

Nice improvement, @kamipo. Could you rebase against the recent changes?

Support for foreign keys in create table
If foreign keys specified in create table, generated SQL is slightly more
efficient.

Definition:

    ```
    create_table :testings do |t|
      t.references :testing_parent, foreign_key: true
    end
    ```

Before:

    ```
    CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer);
    ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id");
    ```

After:

    ```
    CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"));
    ```
@kamipo

This comment has been minimized.

Show comment
Hide comment
@kamipo

kamipo Sep 20, 2015

Member

I rebased on master!

Member

kamipo commented Sep 20, 2015

I rebased on master!

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Sep 20, 2015

Member

Thank you 😁

Member

jeremy commented Sep 20, 2015

Thank you 😁

jeremy added a commit that referenced this pull request Sep 20, 2015

Merge pull request #20009 from kamipo/foreign_keys_in_create
Support for foreign keys in create table

@jeremy jeremy merged commit 2395b02 into rails:master Sep 20, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kamipo kamipo deleted the kamipo:foreign_keys_in_create branch Sep 20, 2015

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Sep 21, 2015

Member

@kamipo @jeremy thank you 💛

Member

senny commented Sep 21, 2015

@kamipo @jeremy thank you 💛

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Sep 26, 2015

Member

🎉 🎊

Member

indirect commented Sep 26, 2015

🎉 🎊

yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Jun 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment