Created
May 15, 2018 06:19
-
-
Save shernshiou/d56832fad59a46fba04e08d3145d1479 to your computer and use it in GitHub Desktop.
Knex createtable sqlite uuid
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
let uuidGenerationRaw = connection.client.config.client === 'sqlite3' ? | |
`(lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6))))` : | |
`uuid_generate_v4()`; | |
connection.schema.createTableIfNotExists('notification', (table) => { | |
table.uuid('id').primary().defaultTo(connection.raw(uuidGenerationRaw)); | |
// ... rest of the columns | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment