mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
34 lines
842 B
TypeScript
34 lines
842 B
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema';
|
|
|
|
export default class extends BaseSchema {
|
|
protected tableName = 'links';
|
|
|
|
async up() {
|
|
this.schema.createTable(this.tableName, (table) => {
|
|
table.uuid('id').unique().notNullable();
|
|
|
|
table.string('name', 254).notNullable();
|
|
table.string('description', 254);
|
|
table.text('url').notNullable();
|
|
table.boolean('favorite').notNullable().defaultTo(0);
|
|
table
|
|
.uuid('collection_id')
|
|
.references('id')
|
|
.inTable('collections')
|
|
.onDelete('CASCADE');
|
|
table
|
|
.uuid('author_id')
|
|
.references('id')
|
|
.inTable('users')
|
|
.onDelete('CASCADE');
|
|
|
|
table.timestamp('created_at');
|
|
table.timestamp('updated_at');
|
|
});
|
|
}
|
|
|
|
async down() {
|
|
this.schema.dropTable(this.tableName);
|
|
}
|
|
}
|