fix: relations between tables

This commit is contained in:
Sonny
2024-04-28 23:25:01 +02:00
committed by Sonny
parent 97044907ee
commit 31f22d382e
6 changed files with 59 additions and 10 deletions

View File

@@ -5,14 +5,22 @@ export default class extends BaseSchema {
async up() {
this.schema.createTable(this.tableName, (table) => {
table.uuid('id').notNullable();
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').notNullable();
table.uuid('author_id').notNullable();
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');