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 Unique Constraint with tests #5

Open
3 tasks done
marcotas opened this issue Jun 19, 2022 · 0 comments
Open
3 tasks done

Add Unique Constraint with tests #5

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

Comments

@marcotas
Copy link
Contributor

marcotas commented Jun 19, 2022

For column schema:

table.string('email').unique();
// can provide a name for the constraint
table.string('email').unique('some_name');

For the table schema:

table.unique(['name']);
// or
table.unique(['name', 'email']);
  • For create operation:
create table "test" ("email" varchar(255) unique)
  • For update operation:
alter table "test"
alter column "email" type varchar(255)
alter column "email" add constraint "test_email_unique" unique ("email");
  • Drop operation
table.dropUnique('name_unique');

Generates:

alter table "test" drop constraint "name_unique"
@marcotas marcotas added this to the v1.0.0 milestone Jun 19, 2022
@marcotas marcotas moved this to 🏗 In progress in Tunder Jun 20, 2022
@marcotas marcotas moved this from 🏗 In progress to 📖 To Doc in Tunder Jun 20, 2022
@marcotas marcotas self-assigned this Jul 22, 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