feat: 🎉 Rating Orama!
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15.2-alpine
|
||||
container_name: postgres-dev
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
volumes:
|
||||
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql
|
||||
- ./data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
@@ -0,0 +1,32 @@
|
||||
Table tv_show {
|
||||
show_id integer [pk]
|
||||
title varchar [not null]
|
||||
runtime integer [not null]
|
||||
popularity integer [not null, default: 0]
|
||||
created_at timestamp [not null, default: `now()`]
|
||||
updated_at timestamp [not null, default: `now()`]
|
||||
|
||||
|
||||
indexes {
|
||||
show_id
|
||||
title
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
|
||||
Table episodes {
|
||||
episode_id integer [pk]
|
||||
tv_show_id integer [not null]
|
||||
season_number integer [not null]
|
||||
title varchar [not null]
|
||||
number int [not null]
|
||||
aired date [not null]
|
||||
avg_rating decimal [not null]
|
||||
votes int [not null]
|
||||
|
||||
indexes {
|
||||
avg_rating
|
||||
}
|
||||
}
|
||||
|
||||
Ref: "tv_show"."show_id" < "episodes"."tv_show_id"
|
||||
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE IF NOT EXISTS "tv_show" (
|
||||
"show_id" integer PRIMARY KEY,
|
||||
"title" varchar NOT NULL,
|
||||
"runtime" integer NOT NULL,
|
||||
"popularity" integer NOT NULL DEFAULT 0,
|
||||
"created_at" timestamp NOT NULL DEFAULT (now()),
|
||||
"updated_at" timestamp NOT NULL DEFAULT (now())
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "episodes" (
|
||||
"episode_id" integer PRIMARY KEY,
|
||||
"tv_show_id" integer NOT NULL,
|
||||
"season_number" integer NOT NULL,
|
||||
"title" varchar NOT NULL,
|
||||
"number" int NOT NULL,
|
||||
"aired" date NOT NULL,
|
||||
"avg_rating" numeric NOT NULL,
|
||||
"votes" int NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tv_show_show_id ON "tv_show" ("show_id");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tv_show_title ON "tv_show" ("title");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tv_show_updated_at ON "tv_show" ("updated_at");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_episodes_avg_rating ON "episodes" ("avg_rating");
|
||||
|
||||
ALTER TABLE "episodes" ADD FOREIGN KEY ("tv_show_id") REFERENCES "tv_show" ("show_id");
|
||||
Reference in New Issue
Block a user