This project is archived and is in readonly mode.
Unsigned integers for MySQL
-
Pratik
- State changed from new to incomplete
- Assigned user set to Pratik
Not a good idea to create unsigned primary keys by default. However, Rails should allow people to do it nevertheless. I think the format could be something like :
create_table(:categories_suppliers, :id => :unsigned) do |t| .... end -
Rob Anderton
Updated patch attached: this doesn't touch the primary keys at all, it just adds an :unsigned option to migrations.
I have some other, non-MySQL specific, ideas for primary key options, and will submit these in a separate patch (which will also include the ability for specifying an unsigned PK in MySQL) when I've had chance to work on them.
-
Jason L Perry
- Tag set to activerecord, migrations, patch
@pratik: Why is it not a good idea to create unsigned primary keys by default? I've read over the mailing list thread related to this ticket (http://www.ruby-forum.com/topic/..., is your concern just regarding backward compatibility?
That said, I'd really like to be able to use :unsigned => true in migrations, regardless of any changes to the primary keys.
-
Rob Anderton
My understanding from the discussions was that changing the default would break backwards compatibility and that even though, as I pointed out, changes to the behaviour of the :limit option on numeric columns did the same thing, it wasn't acceptable for this patch.
I'm still intending to either release a more configurable patch (there's a bit more I'd like to do with primary keys) or a plugin. Hopefully I'll get chance over the next few weeks as it's been on my todo list for too long now :)
In the meantime I've uploaded the monkey-patch edition, which I've been using successfully on recent projects, to my blog
-
Jérémy Lecour
I don't really know where Rails is right now about this, but it sure would be usefull to be able to create unsigned integer columns from migrations.
-
Gabe da Silveira
Going to add my request for :unsigned => true configuration option. I don't so much care about the primary key issue. But unsigned ints are extremely useful for one very common reason: IP Addresses.
-
Rob Anderton
If there was a likelihood of it making it into core I'd be happy to look at updating the patch for Rails 3. I know that other database-specific stuff has made it into core in the (almost) 2 years since I first looked at this, so maybe it'd be more acceptable now.
-
Chip
- Tag changed from activerecord, migrations, patch to mysql adapter, activerecord, migrations, patch
- Importance changed from to
"I know that other database-specific stuff has made it into core in the (almost) 2 years since I first looked at this, so maybe it'd be more acceptable now."
I agree... Rails has recently added support for MySQL's 'after' functionality - showing the db_adapters are a great place for advanced DB-specific features. Rails has always done a great job incorporating best practices, and efficiently using your DB is certainly a 'best practice'.
-
Santiago Pastorino
- State changed from incomplete to open
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 core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
-
Greg Hazel
- State changed from stale to open
[state:open]
The primary key change is not interesting to me, but:
+1 for unsigned integer support.
