Last active
August 16, 2016 18:26
-
-
Save krainboltgreene/5a3b35f0f5724cba06deb9a40f8c2ced to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export default (schema) => { | |
return { | |
...schema, | |
accounts: { | |
columns: { | |
id: {type: "uuid", primary: true, defaultTo: "uuid4"}, | |
fullName: {type: "text", nullable: false, defaultTo: "", index: true}, | |
email: {type: "text", nullable: false, unique: true}, | |
active: {type: "boolean", nullable: false, defaultTo: false} | |
} | |
}, | |
indexes: { | |
...schema.indexes, | |
accountsEmailAndFullName: {unique: true}, | |
accountsInactive: {query: `WHERE "accounts"."active" IS FALSE`} | |
} | |
} | |
} |
This file contains hidden or 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
export default (schema) => { | |
return { | |
...schema, | |
accounts: { | |
...schema.accounts, | |
name: schema.accounts.fullName | |
} | |
indexes: { | |
...schema.indexes, | |
accountsEmailAndFullName: {unique: true} | |
} | |
} | |
} |
This file contains hidden or 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
import {omit} from "ramda" | |
export default (schema) => { | |
return { | |
...schema, | |
accounts: omit("fullName", schema.accounts), | |
indexes: omit("accountsEmailAndFullName", schema.accounts) | |
} | |
} |
This file contains hidden or 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
{ | |
"accounts": { | |
"columns": { | |
"id": { | |
"type": "uuid", | |
"primary": true, | |
"defaultTo": "uuid4" | |
}, | |
"name": { | |
"type": "text", | |
"nullable": false, | |
"defaultTo": "" | |
}, | |
"email": { | |
"type": "text", | |
"nullable": false | |
}, | |
"active": { | |
"type": "boolean", | |
"nullable": false, | |
"defaultTo": false | |
} | |
} | |
}, | |
"indexes": { | |
"accountsName": true, | |
"accountsEmail": { | |
"unique": true | |
}, | |
"accountsEmailAndFullName": { | |
"unique": true | |
}, | |
"accountsInactive": { | |
"query": "WHERE \"accounts\".\"active\" IS FALSE" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment