Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/models/department.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import vine from "@vinejs/vine";
import { DateTime } from "luxon";

import { BaseModel, belongsTo, hasMany } from "@adonisjs/lucid/orm";
Expand Down Expand Up @@ -30,10 +31,16 @@ export default class Department extends BaseModel {
@typedColumn({ type: Branch })
declare branch: Branch;

@typedColumn({ type: "string" })
@typedColumn({
type: "string",
validator: vine.string().trim().minLength(1).maxLength(30),
})
declare code: string;

@typedColumn({ type: "string" })
@typedColumn({
type: "string",
validator: vine.string().trim().minLength(1).maxLength(30),
})
declare betterCode: string;

@typedColumn({ foreignKeyOf: () => FileEntry, optional: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { BaseSchema } from "@adonisjs/lucid/schema";

export default class extends BaseSchema {
protected tableName = "departments";

async up() {
this.schema.alterTable(this.tableName, (table) => {
table.string("code", 30).notNullable().alter();
table.string("better_code", 30).notNullable().alter();
});
}

async down() {
this.schema.alterTable(this.tableName, (table) => {
table.string("code", 3).notNullable().alter();
table.string("better_code", 5).notNullable().alter();
});
}
}
Loading