mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Manually fix migrations and startup
This commit is contained in:
parent
8d01a87b6c
commit
d3fc3894bc
@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS "kyoo"."shows" (
|
|||||||
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||||
"slug" varchar(255) NOT NULL,
|
"slug" varchar(255) NOT NULL,
|
||||||
"kind" "kyoo"."show_kind" NOT NULL,
|
"kind" "kyoo"."show_kind" NOT NULL,
|
||||||
"genres" genres[] NOT NULL,
|
"genres" "kyoo"."genres"[] NOT NULL,
|
||||||
"rating" smallint,
|
"rating" smallint,
|
||||||
"status" "kyoo"."show_status" NOT NULL,
|
"status" "kyoo"."show_status" NOT NULL,
|
||||||
"startAir" date,
|
"startAir" date,
|
||||||
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS "kyoo"."shows" (
|
|||||||
"nextRefresh" timestamp with time zone,
|
"nextRefresh" timestamp with time zone,
|
||||||
CONSTRAINT "shows_id_unique" UNIQUE("id"),
|
CONSTRAINT "shows_id_unique" UNIQUE("id"),
|
||||||
CONSTRAINT "shows_slug_unique" UNIQUE("slug"),
|
CONSTRAINT "shows_slug_unique" UNIQUE("slug"),
|
||||||
CONSTRAINT "ratingValid" CHECK (0 <= "shows"."rating" && "shows"."rating" <= 100)
|
CONSTRAINT "ratingValid" CHECK ("shows"."rating" between 0 and 100)
|
||||||
);
|
);
|
||||||
--> statement-breakpoint
|
--> statement-breakpoint
|
||||||
ALTER TABLE "kyoo"."entries" ADD COLUMN "createdAt" timestamp with time zone DEFAULT now();--> statement-breakpoint
|
ALTER TABLE "kyoo"."entries" ADD COLUMN "createdAt" timestamp with time zone DEFAULT now();--> statement-breakpoint
|
||||||
|
@ -391,7 +391,7 @@
|
|||||||
"checkConstraints": {
|
"checkConstraints": {
|
||||||
"ratingValid": {
|
"ratingValid": {
|
||||||
"name": "ratingValid",
|
"name": "ratingValid",
|
||||||
"value": "0 <= \"shows\".\"rating\" && \"shows\".\"rating\" <= 100"
|
"value": "\"shows\".\"rating\" between 0 and 100"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export const db = drizzle({
|
|||||||
database: process.env.POSTGRES_DB ?? "kyooDB",
|
database: process.env.POSTGRES_DB ?? "kyooDB",
|
||||||
host: process.env.POSTGRES_SERVER ?? "postgres",
|
host: process.env.POSTGRES_SERVER ?? "postgres",
|
||||||
port: Number(process.env.POSTGRES_PORT) || 5432,
|
port: Number(process.env.POSTGRES_PORT) || 5432,
|
||||||
ssl: true,
|
ssl: false,
|
||||||
},
|
},
|
||||||
casing: "snake_case",
|
casing: "snake_case",
|
||||||
});
|
});
|
||||||
|
@ -70,7 +70,7 @@ export const shows = schema.table(
|
|||||||
(t) => ({
|
(t) => ({
|
||||||
ratingValid: check(
|
ratingValid: check(
|
||||||
"ratingValid",
|
"ratingValid",
|
||||||
sql`0 <= ${t.rating} && ${t.rating} <= 100`,
|
sql`${t.rating} between 0 and 100`,
|
||||||
),
|
),
|
||||||
runtimeValid: check("runtimeValid", sql`0 <= ${t.runtime}`),
|
runtimeValid: check("runtimeValid", sql`0 <= ${t.runtime}`),
|
||||||
}),
|
}),
|
||||||
|
@ -5,18 +5,25 @@ import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|||||||
import { movies } from "./controllers/movies";
|
import { movies } from "./controllers/movies";
|
||||||
import jwt from "@elysiajs/jwt";
|
import jwt from "@elysiajs/jwt";
|
||||||
|
|
||||||
await migrate(db, { migrationsFolder: "" });
|
await migrate(db, { migrationsSchema: "kyoo", migrationsFolder: "./drizzle" });
|
||||||
|
|
||||||
|
if (process.env.SEED) {
|
||||||
|
}
|
||||||
|
|
||||||
let secret = process.env.JWT_SECRET;
|
let secret = process.env.JWT_SECRET;
|
||||||
if (!secret) {
|
if (!secret) {
|
||||||
const auth = process.env.AUTH_SERVER ?? "http://auth:4568";
|
const auth = process.env.AUTH_SERVER ?? "http://auth:4568";
|
||||||
const ret = await fetch(`${auth}/info`);
|
try {
|
||||||
const info = await ret.json();
|
const ret = await fetch(`${auth}/info`);
|
||||||
secret = info.publicKey;
|
const info = await ret.json();
|
||||||
|
secret = info.publicKey;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Can't access auth server at ${auth}:\n${error}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!secret) {
|
if (!secret) {
|
||||||
console.error("missing jwt secret or auth server. exiting");
|
console.error("Missing jwt secret or auth server. exiting");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user