Skip to content

Commit fb6a3c2

Browse files
authored
fix: use uuid as migration id when inserting new migration row (#4)
1 parent 9ca18f5 commit fb6a3c2

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Deploy Player
22

33
on:
44
push:
5-
branches: ["master"]
5+
branches: ["main"]
66
pull_request:
7-
branches: ["master"]
7+
branches: ["main"]
88

99
jobs:
1010
build:

src/driver/spanner/SpannerDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class SpannerDriver implements Driver {
139139
deleteDateNullable: true,
140140
version: "int64",
141141
treeLevel: "int64",
142-
migrationId: "int64",
142+
migrationId: "string",
143143
migrationName: "string",
144144
migrationTimestamp: "int64",
145145
cacheId: "string",

src/migration/MigrationExecutor.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { v4 as uuidv4 } from "uuid"
2+
13
import { Table } from "../schema-builder/table/Table"
24
import { DataSource } from "../data-source/DataSource"
35
import { Migration } from "./Migration"
@@ -464,7 +466,9 @@ export class MigrationExecutor {
464466
.migrationId,
465467
}),
466468
isGenerated: true,
467-
generationStrategy: "increment",
469+
generationStrategy: this.connection.driver.options.type === "spanner"
470+
? "uuid"
471+
: "increment",
468472
isPrimary: true,
469473
isNullable: false,
470474
},
@@ -616,6 +620,12 @@ export class MigrationExecutor {
616620
values["timestamp"] = migration.timestamp
617621
values["name"] = migration.name
618622
}
623+
624+
if(this.connection.driver.options.type === "spanner"){
625+
// spanner cannot auto generate id's so need to generate ids when inserting a migration
626+
values["id"] = uuidv4()
627+
}
628+
619629
if (this.connection.driver.options.type === "mongodb") {
620630
const mongoRunner = queryRunner as MongoQueryRunner
621631
await mongoRunner.databaseConnection

0 commit comments

Comments
 (0)