Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 2f11865

Browse files
bpamiriclaude
andcommitted
Use explicit IDs for roles seed data in migration
CockroachDB uses unique_rowid() instead of sequential auto-increment, so role IDs are not 1,2,3. The users insert references role_id=1 via foreign key, so roles must have explicit IDs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2210653 commit 2f11865

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

app/migrator/migrations/20250306112302_insert_records.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ component extends="wheels.migrator.Migration" hint="insert records" {
77
// 1. Converts boolean true/false to integer 1/0 (IsNumeric check)
88
// 2. Calls get("adapterName") for date columns which doesn't exist in this context
99

10-
// roles
11-
execute("INSERT INTO roles (name, createdat, updatedat) VALUES ('admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
12-
execute("INSERT INTO roles (name, createdat, updatedat) VALUES ('editor', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
13-
execute("INSERT INTO roles (name, createdat, updatedat) VALUES ('user', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
10+
// roles (explicit IDs because CockroachDB unique_rowid() doesn't produce sequential integers)
11+
execute("INSERT INTO roles (id, name, createdat, updatedat) VALUES (1, 'admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
12+
execute("INSERT INTO roles (id, name, createdat, updatedat) VALUES (2, 'editor', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
13+
execute("INSERT INTO roles (id, name, createdat, updatedat) VALUES (3, 'user', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
1414

1515
// users
1616
execute("INSERT INTO users (first_name, last_name, email, password_hash, profile_picture, profile_url, status, role_id, createdat, updatedat) VALUES ('Peter', 'Amiri', 'petera@pai.com', '$2a$10$P27CV/m.aramHhIxJTmzzu4dxIGfNqHWzLgVGJJTLDpXymnt4jPZu', 'avatar-rounded.webp', '', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");

0 commit comments

Comments
 (0)