Skip to content

Commit 9740606

Browse files
committed
Create column groups.kind
1 parent 9d26d2b commit 9740606

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as Knex from 'knex'
2+
3+
export async function up(knex: Knex): Promise<void> {
4+
return knex.schema.alterTable('groups', table => {
5+
table.enu('kind', ['classic', 'anonymous'], {
6+
useNative: true,
7+
enumName: 'group_kind'
8+
}).defaultTo('classic')
9+
})
10+
}
11+
12+
export async function down(knex: Knex): Promise<void> {
13+
return knex.schema.alterTable('groups', table => {
14+
table.dropColumn('kind')
15+
})
16+
}

src/components/groups/group.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { Model } from 'objection'
22

33
import { User } from '../users/user'
44

5+
export enum GroupKind {
6+
classic = 'classic',
7+
anonymous = 'anonymous'
8+
}
9+
510
export class Group extends Model {
611
id!: number
712
name: string
@@ -18,6 +23,8 @@ export class Group extends Model {
1823
createdAt: Date
1924
maxAttendees: number
2025

26+
kind = GroupKind.classic
27+
2128
$beforeInsert(): void {
2229
this.createdAt = new Date()
2330
}
@@ -63,7 +70,8 @@ export class Group extends Model {
6370
place: { type: 'string' },
6471
startDate: { type: 'datetime' },
6572
endDate: { type: 'datetime' },
66-
maxAttendees: { type: 'integer' }
73+
maxAttendees: { type: 'integer' },
74+
kind: { type: 'string' }
6775
}
6876
}
6977
}

0 commit comments

Comments
 (0)