Skip to content
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

Add Primary Key Constraint with tests #6

Open
4 tasks done
marcotas opened this issue Jun 20, 2022 · 0 comments
Open
4 tasks done

Add Primary Key Constraint with tests #6

marcotas opened this issue Jun 20, 2022 · 0 comments
Assignees
Milestone

Comments

@marcotas
Copy link
Contributor

marcotas commented Jun 20, 2022

  • Create

In Column

table.bigInteger('id').primary();
// or 
table.bigInteger('id').primary('custom_name')

In Table

table.primary(['id', 'customer_id']);
// or
table.primary(['id', ...], name: 'custom_name_pkey');
  • Update

Column

Adding a column

table.bigInteger('id').primary();
// or 
table.bigInteger('id').primary('custom_name')

Updating existing column

table.bigInteger('id').primary().change();
// or 
table.bigInteger('id').primary('custom_name').change();

Table

table.primary(['id', 'customer_id']);
// or
table.primary(['id'], name: 'custom_name_pkey');
  • Rename
table.renamePrimary('existing', 'new_name');
  • Drop
table.dropPrimary(columns: ['id']);
// or
table.dropPrimary(name: 'some_custom_pk');
@marcotas marcotas self-assigned this Jun 20, 2022
@marcotas marcotas added this to the v1.0.0 milestone Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📖 Documenting
Development

No branches or pull requests

1 participant