Skip to content

Commit

Permalink
fix(migrate): raw types and sql output in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Jun 30, 2020
1 parent 18ca3c7 commit 02725ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/packages/migrate/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export interface Migration {

export interface DatabaseSteps {
step: DatabaseStep
raw: String
}

export interface LocalMigrationWithDatabaseSteps extends LocalMigration {
Expand All @@ -188,26 +189,22 @@ export interface LocalMigrationWithDatabaseSteps extends LocalMigration {

export interface RawSqlStep {
RawSql: string
raw: string
}

export interface DropTableStep {
raw: string
DropTable: {
name: string
}
}

export interface RenameTableStep {
raw: string
RenameTable: {
name: string
new_name: string
}
}

export interface CreateTableStep {
raw: string
CreateTable: {
name: string
columns: CreateColumn[]
Expand All @@ -216,7 +213,6 @@ export interface CreateTableStep {
}

export interface CreateColumn {
raw: string
name: string
tpe: string
required: boolean
Expand Down
7 changes: 5 additions & 2 deletions src/packages/migrate/src/utils/printDatabaseSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function highlightMigrationsSQL(
.map(
(migration) =>
`-- Migration ${migration.id}\n` +
migration.databaseSteps.map((it) => it.step.raw).join('\n'),
migration.databaseSteps.map((it) => it.raw).join('\n'),
)
.join('\n\n') +
'\n\n-- End Migrations',
Expand All @@ -48,7 +48,10 @@ export function highlightMigrationsSQL(
export function printDetailedDatabaseSteps(
databaseSteps: DatabaseSteps[],
): string {
return databaseSteps.map((it) => it.step.raw).join('\n\n')
return databaseSteps
.map((it) => it.raw)
.join('\n\n')
.replace(/"quaint"./g, '') // For SQLite output
}

// const bold = (str) => str
Expand Down

0 comments on commit 02725ac

Please sign in to comment.