No, you canβt. By default, the primary key is an auto-incrementing integer.
However, you can open the migration that was generated from this command and modify it (before running the rake db:migrate command). The migration will likely have a create_table command:
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t|
If you read the create_table documentation, you will notice that you can pass two options. In particular, you need to set :id to false so as not to generate an id field, and you will need to specify the name of the primary key field.
create_table :users, id: false, primary_key: :email do |t|
source share