You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create below tables but unfortunately it is saying I violate unique constraint. Could someone please help? Note: rowmap and colmap has id as primary key. contentmap references rowmap and colmap for their id and I created content as primary key in contentmap table since it was showing another issue of not having primary key
`CREATE TABLE IF NOT EXISTS rowmap (
"id" uuid PRIMARY KEY NOT NULL,
"pos" integer
);
CREATE TABLE IF NOT EXISTS colmap (
"id" uuid PRIMARY KEY NOT NULL,
"pos" integer
);
CREATE TABLE IF NOT EXISTS contentmap (
"rowIndex" uuid NOT NULL REFERENCES rowmap("id") ON DELETE CASCADE,
"colIndex" uuid NOT NULL REFERENCES colmap("id") ON DELETE CASCADE,
"content" TEXT NOT NULL PRIMARY KEY
);
-- ⚡
-- Electrify the items table
ALTER TABLE items ENABLE ELECTRIC;
ALTER TABLE rowmap ENABLE ELECTRIC;
ALTER TABLE colmap ENABLE ELECTRIC;
ALTER TABLE contentmap ENABLE ELECTRIC;
`
Message I expect: DB has been created successfully
Regarding reproducing the error: I am creating the tables for the first time and there is no data as I am just initiating the creation of tables
I am using the command npm run db:migrate to create the tables on postgres via ElectricSQL
Log from the terminal is:
spreadsheet-postgres-1 | 2024-04-22 10:35:36.947 GMT [194] ERROR: duplicate key value violates unique constraint "migration_unique_version" spreadsheet-postgres-1 | 2024-04-22 10:35:36.947 GMT [194] DETAIL: Key (version)=(1) already exists. spreadsheet-postgres-1 | 2024-04-22 10:35:36.947 GMT [194] CONTEXT: SQL statement "INSERT INTO "electric"."migration_versions" AS v (version, priority) VALUES (_version, _priority::int2) spreadsheet-postgres-1 | ON CONFLICT (txid, txts) DO spreadsheet-postgres-1 | UPDATE SET version = EXCLUDED.version, priority = EXCLUDED.priority spreadsheet-postgres-1 | WHERE EXCLUDED.priority > v.priority" spreadsheet-postgres-1 | PL/pgSQL function electric.assign_migration_version(text,integer) line 5 at SQL statement spreadsheet-postgres-1 | 2024-04-22 10:35:36.947 GMT [194] STATEMENT: CALL electric.assign_migration_version($4b8bcbcee498$1$4b8bcbcee498$, 4)
The text was updated successfully, but these errors were encountered:
I am trying to create below tables but unfortunately it is saying I violate unique constraint. Could someone please help? Note: rowmap and colmap has id as primary key. contentmap references rowmap and colmap for their id and I created content as primary key in contentmap table since it was showing another issue of not having primary key
`CREATE TABLE IF NOT EXISTS rowmap (
"id" uuid PRIMARY KEY NOT NULL,
"pos" integer
);
CREATE TABLE IF NOT EXISTS colmap (
"id" uuid PRIMARY KEY NOT NULL,
"pos" integer
);
CREATE TABLE IF NOT EXISTS contentmap (
"rowIndex" uuid NOT NULL REFERENCES rowmap("id") ON DELETE CASCADE,
"colIndex" uuid NOT NULL REFERENCES colmap("id") ON DELETE CASCADE,
"content" TEXT NOT NULL PRIMARY KEY
);
-- ⚡
-- Electrify the items table
ALTER TABLE items ENABLE ELECTRIC;
ALTER TABLE rowmap ENABLE ELECTRIC;
ALTER TABLE colmap ENABLE ELECTRIC;
ALTER TABLE contentmap ENABLE ELECTRIC;
`
Message I expect: DB has been created successfully
Regarding reproducing the error: I am creating the tables for the first time and there is no data as I am just initiating the creation of tables
I am using the command npm run db:migrate to create the tables on postgres via ElectricSQL
Log from the terminal is:
The text was updated successfully, but these errors were encountered: