diff options
author | 2024-02-10 18:37:40 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | e1c47572a6235fd8fd20af888ac3a11c7ae1369d (patch) | |
tree | 2dccff36a441916d7014037cef3f7ce84a790cad /database/migrations/1658076326250_correct_token_relations.ts | |
parent | refactor: project maintenance (diff) | |
download | ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.tar.gz ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.tar.zst ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.zip |
updates
Diffstat (limited to 'database/migrations/1658076326250_correct_token_relations.ts')
-rw-r--r-- | database/migrations/1658076326250_correct_token_relations.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/database/migrations/1658076326250_correct_token_relations.ts b/database/migrations/1658076326250_correct_token_relations.ts index 1013861..a083c88 100644 --- a/database/migrations/1658076326250_correct_token_relations.ts +++ b/database/migrations/1658076326250_correct_token_relations.ts | |||
@@ -1,16 +1,18 @@ | |||
1 | import { BaseSchema } from '@adonisjs/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('DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)') | 7 | await this.db.rawQuery( |
8 | 'DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)', | ||
9 | ); | ||
8 | 10 | ||
9 | this.schema.alterTable(this.tableName, (table) => { | 11 | this.schema.alterTable(this.tableName, table => { |
10 | table.dropForeign('user_id') | 12 | table.dropForeign('user_id'); |
11 | 13 | ||
12 | table.foreign('user_id').references('users.id').onDelete('cascade') | 14 | table.foreign('user_id').references('users.id').onDelete('cascade'); |
13 | }) | 15 | }); |
14 | } | 16 | } |
15 | 17 | ||
16 | public async down(): Promise<void> { | 18 | public async down(): Promise<void> { |