Skip to content

Make docs a bit more clear for no-allow-null-true #1

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

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ without PG having to block writes while the constraint is being added.
The following shows how you can add the constraint on an existing column.
If you are adding a new column (via addColumn) with allowNull: false,
best to add the column first, then add the constraint of NOT NULL safely,
like mentioned below.
like mentioned below using the four statements:

```sql
ALTER TABLE $table-name ADD CONSTRAINT $constraint-name CHECK ($column-name IS NOT NULL) NOT VALID;
1. ALTER TABLE $table-name ADD CONSTRAINT $constraint-name CHECK ($column-name IS NOT NULL) NOT VALID;

ALTER TABLE $table-name validate CONSTRAINT $constraint-name; -- performs seq scan but doesn't block read/writes.
2. ALTER TABLE $table-name validate CONSTRAINT $constraint-name; -- performs seq scan but doesn't block read/writes.

ALTER TABLE $table-name ALTER COLUMN workspace SET NOT NULL;
3. ALTER TABLE $table-name ALTER COLUMN workspace SET NOT NULL;

ALTER TABLE $table-name DROP CONSTRAINT $constraint-name;
4. ALTER TABLE $table-name DROP CONSTRAINT $constraint-name;
```

NOTE: Depending on the size of the table, the `validate` instruction
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/no-allow-null-true/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ without PG having to block writes while the constraint is being added.
The following shows how you can add the constraint on an existing column.
If you are adding a new column (via addColumn) with allowNull: false,
best to add the column first, then add the constraint of NOT NULL safely,
like mentioned below.
like mentioned below using the four statements:

ALTER TABLE $table-name ADD CONSTRAINT $constraint-name CHECK ($column-name IS NOT NULL) NOT VALID;
1. ALTER TABLE $table-name ADD CONSTRAINT $constraint-name CHECK ($column-name IS NOT NULL) NOT VALID;

ALTER TABLE $table-name validate CONSTRAINT $constraint-name; -- performs seq scan but doesn't block read/writes.
2. ALTER TABLE $table-name validate CONSTRAINT $constraint-name; -- performs seq scan but doesn't block read/writes.

ALTER TABLE $table-name ALTER COLUMN workspace SET NOT NULL;
3. ALTER TABLE $table-name ALTER COLUMN workspace SET NOT NULL;

ALTER TABLE $table-name DROP CONSTRAINT $constraint-name;
4. ALTER TABLE $table-name DROP CONSTRAINT $constraint-name;
`;

const testFn = (context) => ({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"pretty": "yarn prettier --write .",
"test:watch": "jest --watchAll"
},
"version": "0.3.0",
"version": "0.3.1",
"main": "./lib/index.js",
"devDependencies": {
"eslint": "^8.6.0",
Expand Down