@donkeylabs/server 2.0.34 → 2.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core.ts +18 -3
package/package.json
CHANGED
package/src/core.ts
CHANGED
|
@@ -544,10 +544,15 @@ export class PluginManager {
|
|
|
544
544
|
* This table tracks which migrations have been applied for each plugin.
|
|
545
545
|
*/
|
|
546
546
|
private async ensureMigrationsTable(): Promise<void> {
|
|
547
|
-
|
|
547
|
+
const table = this.core.db.schema
|
|
548
548
|
.createTable("__donkeylabs_migrations__")
|
|
549
|
-
.ifNotExists()
|
|
550
|
-
|
|
549
|
+
.ifNotExists();
|
|
550
|
+
|
|
551
|
+
const withId = this.isPostgresDialect()
|
|
552
|
+
? table.addColumn("id", "serial", (col) => col.primaryKey())
|
|
553
|
+
: table.addColumn("id", "integer", (col) => col.primaryKey().autoIncrement());
|
|
554
|
+
|
|
555
|
+
await withId
|
|
551
556
|
.addColumn("plugin_name", "text", (col) => col.notNull())
|
|
552
557
|
.addColumn("migration_name", "text", (col) => col.notNull())
|
|
553
558
|
.addColumn("executed_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`))
|
|
@@ -559,6 +564,16 @@ export class PluginManager {
|
|
|
559
564
|
ON __donkeylabs_migrations__(plugin_name, migration_name)`.execute(this.core.db);
|
|
560
565
|
}
|
|
561
566
|
|
|
567
|
+
private isPostgresDialect(): boolean {
|
|
568
|
+
try {
|
|
569
|
+
const adapter = (this.core.db as any).getExecutor?.().adapter;
|
|
570
|
+
const name = adapter?.constructor?.name?.toLowerCase() ?? "";
|
|
571
|
+
return name.includes("postgres");
|
|
572
|
+
} catch {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
562
577
|
/**
|
|
563
578
|
* Checks if a migration has already been applied for a specific plugin.
|
|
564
579
|
*/
|