Skip to content

Commit d2926bb

Browse files
committed
✨ Refactor Remember Me Token Storage with Dedicated Table
1 parent 5f728c0 commit d2926bb

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

database/migrations/1736839410875_create_users_table.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default class extends BaseSchema {
1616
table.boolean('is_admin').defaultTo(false)
1717
table.boolean('is_sponsor').defaultTo(false)
1818
table.timestamp('email_verified_at').nullable()
19-
table.string('remember_me_token').nullable()
2019
table.timestamps(true, true)
2120
})
2221
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { BaseSchema } from '@adonisjs/lucid/schema'
2+
3+
export default class extends BaseSchema {
4+
protected tableName = 'remember_me_tokens'
5+
6+
async up() {
7+
this.schema.createTable(this.tableName, (table) => {
8+
table.increments()
9+
table
10+
.integer('tokenable_id')
11+
.notNullable()
12+
.unsigned()
13+
.references('id')
14+
.inTable('users')
15+
.onDelete('CASCADE')
16+
17+
table.string('hash').notNullable().unique()
18+
table.timestamp('created_at').notNullable()
19+
table.timestamp('updated_at').notNullable()
20+
table.timestamp('expires_at').notNullable()
21+
})
22+
}
23+
24+
async down() {
25+
this.schema.dropTable(this.tableName)
26+
}
27+
}

0 commit comments

Comments
 (0)