Rails does not create non int primary keys #14194

Closed
kassio opened this Issue Feb 25, 2014 · 3 comments

Comments

Projects
None yet
4 participants
@kassio
Contributor

kassio commented Feb 25, 2014

related with: #10505

with the given migration:

class CreateBars < ActiveRecord::Migration
  def change
    create_table :bars, id: false, primary_key: :pk do |t|
      t.primary_key :pk, :string
    end

    create_table :foos, id: false, primary_key: :pk do |t|
      t.primary_key :pk
    end

    create_table :omgs, id: false, primary_key: :pk do |t|
      t.primary_key :pk, :int
    end
  end
end

will generates:

foo_rails$  desc bars;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| pk    | varchar(255) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

foo_rails$  desc foos;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| pk    | int(11) | NO   | PRI | NULL    | auto_increment |
+-------+---------+------+-----+---------+----------------+
1 row in set (0.00 sec)

foo_rails$  desc omgs;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| pk    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

@senny senny added the activerecord label Feb 25, 2014

@rails-bot

This comment has been minimized.

Show comment Hide comment
@rails-bot

rails-bot May 27, 2014

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

@kassio kassio added the stale label May 27, 2014

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Jul 28, 2014

Owner

Hmm, this is something we need to fix. I'll remove the stale tag and assign to me.

Owner

rafaelfranca commented Jul 28, 2014

Hmm, this is something we need to fix. I'll remove the stale tag and assign to me.

@rails-bot

This comment has been minimized.

Show comment Hide comment
@rails-bot

rails-bot Nov 19, 2014

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

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