Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7815baf

Browse files
bwoodltkoistya
authored andcommitted
Add a comment about using UUID v1mc for keys (kriasoft#21)
1 parent e631d84 commit 7815baf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

migrations/201612010000_membership.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ module.exports.up = async (db) => {
1515
await db.raw('CREATE EXTENSION IF NOT EXISTS "hstore"');
1616

1717
await db.schema.createTable('users', (table) => {
18-
table.uuid('id').notNullable().defaultTo(db.raw('uuid_generate_v1mc()')).primary();
18+
// UUID v1mc reduces the negative side effect of using random primary keys
19+
// with respect to keyspace fragmentation on disk for the tables because it's time based
20+
// https://www.postgresql.org/docs/current/static/uuid-ossp.html
21+
table.uuid('id').notNullable().defaultTo(db.raw('uuid_generate_v1mc()')).primary(); // using uuid_generate_v1mc() as v1mc is time-based, which is better for keyspace fragmentation on disk for tables.
1922
table.string('email').unique();
2023
table.boolean('email_confirmed').notNullable().defaultTo(false);
2124
table.string('password_hash', 100);

0 commit comments

Comments
 (0)