-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from AgenceBio/exclude_deleted_from_unique
Exclue les versions supprimées de l'index unique
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
}; | ||
|
||
exports.up = async function(db) { | ||
await db.removeIndex('cartobio_operators', 'cartobio_operators_numerobio_audit_date_idx') | ||
await db.runSql(/* sql */` | ||
CREATE UNIQUE INDEX cartobio_operators_numerobio_audit_date_idx | ||
ON "cartobio_operators" ("numerobio", "audit_date") WHERE cartobio_operators.deleted_at IS NULL | ||
`) | ||
}; | ||
|
||
exports.down = async function(db) { | ||
await db.removeIndex('cartobio_operators', 'cartobio_operators_numerobio_audit_date_idx') | ||
await db.addIndex('cartobio_operators', 'cartobio_operators_numerobio_audit_date_idx', ['numerobio', 'audit_date'], true); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |