diff options
author | 2024-02-10 18:19:14 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 7584d2d7a7110aef0331ebfa178b2295842c59fa (patch) | |
tree | 900cd71237e6231b57936fcce77ff229cd459041 /database/migrations/1658076326250_correct_token_relations.ts | |
parent | upgrade recipes submodule (diff) | |
download | ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip |
refactor: project maintenance
- work in progress
Diffstat (limited to 'database/migrations/1658076326250_correct_token_relations.ts')
-rw-r--r-- | database/migrations/1658076326250_correct_token_relations.ts | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/database/migrations/1658076326250_correct_token_relations.ts b/database/migrations/1658076326250_correct_token_relations.ts index 5486657..1013861 100644 --- a/database/migrations/1658076326250_correct_token_relations.ts +++ b/database/migrations/1658076326250_correct_token_relations.ts | |||
@@ -1,18 +1,16 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/Lucid/Schema'; | 1 | import { BaseSchema } from '@adonisjs/lucid/schema' |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'tokens'; | 4 | protected tableName = 'tokens' |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | await this.db.rawQuery( | 7 | await this.db.rawQuery('DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)') |
8 | 'DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)', | ||
9 | ); | ||
10 | 8 | ||
11 | this.schema.alterTable(this.tableName, table => { | 9 | this.schema.alterTable(this.tableName, (table) => { |
12 | table.dropForeign('user_id'); | 10 | table.dropForeign('user_id') |
13 | 11 | ||
14 | table.foreign('user_id').references('users.id').onDelete('cascade'); | 12 | table.foreign('user_id').references('users.id').onDelete('cascade') |
15 | }); | 13 | }) |
16 | } | 14 | } |
17 | 15 | ||
18 | public async down(): Promise<void> { | 16 | public async down(): Promise<void> { |