generated from AthennaIO/Template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(driver): implement sqlite driver
- Loading branch information
Showing
16 changed files
with
4,197 additions
and
4 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
tests/fixtures/migrations/2022_10_08_000006_create_users_sqlite_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { DatabaseImpl, Migration } from '#src' | ||
|
||
export class UserMigration extends Migration { | ||
public static connection() { | ||
return 'sqlite-memory' | ||
} | ||
|
||
public tableName = 'users' | ||
|
||
public async up(db: DatabaseImpl) { | ||
return db.createTable(this.tableName, table => { | ||
table.increments('id') | ||
table.string('name') | ||
table.string('email').unique() | ||
table.timestamps(true, true, true) | ||
table.dateTime('deletedAt').nullable().defaultTo(null) | ||
}) | ||
} | ||
|
||
public async down(db: DatabaseImpl) { | ||
return db.dropTable(this.tableName) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/fixtures/migrations/2022_10_08_000007_create_products_sqlite_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DatabaseImpl, Migration } from '#src' | ||
|
||
export class ProductMigration extends Migration { | ||
public static connection() { | ||
return 'sqlite-memory' | ||
} | ||
|
||
public tableName = 'products' | ||
|
||
public async up(db: DatabaseImpl) { | ||
return db.createTable(this.tableName, table => { | ||
table.increments('id') | ||
table.string('name', 255) | ||
table.integer('price').defaultTo(0) | ||
table.integer('userId').unsigned().index().references('id').inTable('users') | ||
|
||
table.timestamps(true, true, true) | ||
table.dateTime('deletedAt').nullable().defaultTo(null) | ||
}) | ||
} | ||
|
||
public async down(db: DatabaseImpl) { | ||
return db.dropTable(this.tableName) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/fixtures/migrations/2022_10_08_000008_create_products_details_sqlite_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { DatabaseImpl, Migration } from '#src' | ||
|
||
export class ProductDetailsMigration extends Migration { | ||
public static connection() { | ||
return 'sqlite-memory' | ||
} | ||
|
||
public tableName = 'product_details' | ||
|
||
public async up(db: DatabaseImpl) { | ||
return db.createTable(this.tableName, table => { | ||
table.increments('id') | ||
table.string('content', 255) | ||
table.integer('productId').unsigned().index().references('id').inTable('products') | ||
|
||
table.timestamps(true, true, true) | ||
table.dateTime('deletedAt').nullable().defaultTo(null) | ||
}) | ||
} | ||
|
||
public async down(db: DatabaseImpl) { | ||
return db.dropTable(this.tableName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.