remove all drops from sql files, add triggers and functions for updated_at, added files and folder tables, update some types
This commit is contained in:
parent
6fdc82dd49
commit
94ba46cc2d
11 changed files with 295 additions and 101 deletions
|
@ -1,6 +1,8 @@
|
|||
import { logger } from "@helpers/logger";
|
||||
import { type ReservedSQL, sql } from "bun";
|
||||
|
||||
export const order: number = 3;
|
||||
|
||||
export async function createTable(reservation?: ReservedSQL): Promise<void> {
|
||||
let selfReservation: boolean = false;
|
||||
|
||||
|
@ -29,26 +31,3 @@ export async function createTable(reservation?: ReservedSQL): Promise<void> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function drop(
|
||||
cascade: boolean,
|
||||
reservation?: ReservedSQL,
|
||||
): Promise<void> {
|
||||
let selfReservation: boolean = false;
|
||||
|
||||
if (!reservation) {
|
||||
reservation = await sql.reserve();
|
||||
selfReservation = true;
|
||||
}
|
||||
|
||||
try {
|
||||
await reservation`DROP TABLE IF EXISTS invites ${cascade ? "CASCADE" : ""};`;
|
||||
} catch (error) {
|
||||
logger.error(["Could not drop the invites table:", error as Error]);
|
||||
throw error;
|
||||
} finally {
|
||||
if (selfReservation) {
|
||||
reservation.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue