Skip to content

Commit c58653f

Browse files
Xevifbaldi6
authored andcommitted
fix: use uuid as migration id when inserting new migration row (#4)
1 parent 7a0daf2 commit c58653f

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
@@ -140,7 +140,7 @@ export class SpannerDriver implements Driver {
140140
deleteDateNullable: true,
141141
version: "int64",
142142
treeLevel: "int64",
143-
migrationId: "int64",
143+
migrationId: "string",
144144
migrationName: "string",
145145
migrationTimestamp: "int64",
146146
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"
@@ -515,7 +517,9 @@ export class MigrationExecutor {
515517
.migrationId,
516518
}),
517519
isGenerated: true,
518-
generationStrategy: "increment",
520+
generationStrategy: this.connection.driver.options.type === "spanner"
521+
? "uuid"
522+
: "increment",
519523
isPrimary: true,
520524
isNullable: false,
521525
},
@@ -665,6 +669,12 @@ export class MigrationExecutor {
665669
values["timestamp"] = migration.timestamp
666670
values["name"] = migration.name
667671
}
672+
673+
if(this.connection.driver.options.type === "spanner"){
674+
// spanner cannot auto generate id's so need to generate ids when inserting a migration
675+
values["id"] = uuidv4()
676+
}
677+
668678
if (this.connection.driver.options.type === "mongodb") {
669679
const mongoRunner = queryRunner as MongoQueryRunner
670680
await mongoRunner.databaseConnection

0 commit comments

Comments
 (0)