-
Notifications
You must be signed in to change notification settings - Fork 95
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
how can i add auto_increment column to work with mysql and postgres databases? #169
Comments
The Postgres analog to MySQL
To achieve this: $t = $this->create_table('animals');
// will automatically give you an `id` column of type `serial` If you wanted a different name than // specify id=false so the default primary key is ignored
$table = $bm->create_table('animals', array('id' => false));
$table->column('user_id', 'integer', array('primary_key' => true, 'auto_increment' => true));
$sql = $table->finish(); |
@ruckus thanks for answer, but just option 'primary_key' is not works. but if i set 'primary_key' as column type (not integer) it works perfect. |
@ruckus i am able to create primary key with different column name but I want to specify my own keyname/constraint name so that sql for that should be like below Thanks |
Hi @jaffarhussain1011 - you cannot specify a constraint in the same // ... column calls
$table->finish();
$this->execute("ALTER TABLE foobar ADD CONSTRAINT ..."); |
Ok, Thanks for prompt reply. |
I want to create migration for mysql and postgres databases, but i need an autoincrement column. For mysql it`s simple, auto_increment option works well. but how about postgres?
The text was updated successfully, but these errors were encountered: