Skip to content

Commit 582fa5c

Browse files
chore: wip
1 parent 45771b0 commit 582fa5c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/migrations.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ export function generateSql(plan: MigrationPlan): string[] {
161161

162162
const columnSql = (c: ColumnPlan): string => {
163163
const typeSql = (() => {
164+
// For PostgreSQL, use SERIAL types for auto-incrementing primary keys
165+
if (plan.dialect === 'postgres' && c.isPrimaryKey) {
166+
switch (c.type) {
167+
case 'integer': return 'SERIAL'
168+
case 'bigint': return 'BIGSERIAL'
169+
default: break
170+
}
171+
}
172+
164173
switch (c.type) {
165174
case 'string': return plan.dialect === 'mysql' ? 'varchar(255)' : 'varchar(255)'
166175
case 'text': return 'text'

test/client.hooks-softdeletes-relations-cursor.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { beforeAll, describe, expect, it } from 'bun:test'
22
import { buildDatabaseSchema, buildSchemaMeta, createQueryBuilder, defineModel, defineModels } from '../src'
3-
import { executeMigration, generateMigration } from '../src/actions/migrate'
43
import { config } from '../src/config'
54
import { mockQueryBuilderState } from './utils'
65

test/migrations.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { beforeAll, describe, expect, it } from 'bun:test'
2-
import { executeMigration, generateMigration } from '../src/actions/migrate'
32
import { config } from '../src/config'
43
import { buildMigrationPlan, generateSql } from '../src/migrations'
54
import { defineModels } from '../src/schema'

test/schema_meta.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeAll, describe, expect, it } from 'bun:test'
2+
import { buildDatabaseSchema, buildSchemaMeta, defineModels } from '../src'
23
import { executeMigration, generateMigration } from '../src/actions/migrate'
34
import { config } from '../src/config'
4-
import { buildDatabaseSchema, buildSchemaMeta, defineModels } from '../src'
55

66
beforeAll(async () => {
77
if (config.debug)
@@ -14,7 +14,8 @@ beforeAll(async () => {
1414
if (result.sqlStatements.length > 0) {
1515
await executeMigration(result.sqlStatements)
1616
}
17-
} catch (error) {
17+
}
18+
catch (error) {
1819
console.error('Migration failed:', error)
1920
}
2021
})

0 commit comments

Comments
 (0)