From 7cddffe5f05a543e7d839e6e4548aac06c4e8d0f Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Tue, 15 Mar 2022 18:58:47 +0100 Subject: [PATCH] feat: #be tables for games, clues and shots --- backend/migrations/20220315171314_games.ts | 13 +++++++++++++ backend/migrations/20220315171328_clues.ts | 15 +++++++++++++++ backend/migrations/20220315171336_shots.ts | 17 +++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 backend/migrations/20220315171314_games.ts create mode 100644 backend/migrations/20220315171328_clues.ts create mode 100644 backend/migrations/20220315171336_shots.ts diff --git a/backend/migrations/20220315171314_games.ts b/backend/migrations/20220315171314_games.ts new file mode 100644 index 0000000..703e2d7 --- /dev/null +++ b/backend/migrations/20220315171314_games.ts @@ -0,0 +1,13 @@ +import { Knex } from "knex"; + +export async function up(knex: Knex): Promise<void> { + return knex.schema.createTable("games", function (table) { + table.uuid("id").primary().defaultTo(knex.raw("gen_random_uuid()")); + table.timestamp("began_at"); + table.timestamp("ended_at"); + }); +} + +export async function down(knex: Knex): Promise<void> { + return knex.schema.dropTable("games"); +} diff --git a/backend/migrations/20220315171328_clues.ts b/backend/migrations/20220315171328_clues.ts new file mode 100644 index 0000000..e8d57a0 --- /dev/null +++ b/backend/migrations/20220315171328_clues.ts @@ -0,0 +1,15 @@ +import { Knex } from "knex"; + +export async function up(knex: Knex): Promise<void> { + return knex.schema.createTable("clues", function (table) { + table.uuid("id").primary().defaultTo(knex.raw("gen_random_uuid()")); + table.uuid("game_id").references("games.id").notNullable(); + table.uuid("word_id").references("words.id").notNullable(); + table.timestamp("began_at"); + table.timestamp("ended_at"); + }); +} + +export async function down(knex: Knex): Promise<void> { + return knex.schema.dropTable("clues"); +} diff --git a/backend/migrations/20220315171336_shots.ts b/backend/migrations/20220315171336_shots.ts new file mode 100644 index 0000000..9781b2a --- /dev/null +++ b/backend/migrations/20220315171336_shots.ts @@ -0,0 +1,17 @@ +import { Knex } from "knex"; + +export async function up(knex: Knex): Promise<void> { + return knex.schema.createTable("shots", function (table) { + table.uuid("id").primary().defaultTo(knex.raw("gen_random_uuid()")); + table.uuid("game_id").references("games.id").notNullable(); + table.uuid("clue_id").references("clues.id"); + table.timestamp("began_at"); + table.timestamp("ended_at"); + table.string("typed"); + table.string("final"); + }); +} + +export async function down(knex: Knex): Promise<void> { + return knex.schema.dropTable("shots"); +} -- GitLab