CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE "USER" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
"name" varchar(50) NOT NULL,
"email" varchar(320) UNIQUE NOT NULL,
"role" varchar(20) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"updated_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "SKILL" (
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
"name" varchar(50) UNIQUE NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
INSERT INTO "SKILL" (name) VALUES ('重訓'), ('瑜伽'), ('有氧運動'), ('復健訓練');
CREATE TABLE "COACH" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"experience_years" integer,
"description" text,
"profile_image_url" varchar(2048),
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"updated_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
UNIQUE("user_id")
);
CREATE TABLE "COACH_LINK_SKILL" (
"coach_id" uuid NOT NULL REFERENCES "COACH"(id),
"skill_id" uuid NOT NULL REFERENCES "SKILL"(id),
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY ("coach_id", "skill_id")
);
CREATE TABLE "CREDIT_PACKAGE" (
"id" serial PRIMARY KEY,
"name" varchar(50) NOT NULL,
"credit_amount" integer NOT NULL,
"price" numeric(10,2) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "CREDIT_PURCHASE" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"credit_package_id" integer NOT NULL REFERENCES "CREDIT_PACKAGE"(id),
"purchased_credits" integer NOT NULL,
"price_paid" numeric(10,2) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"purchase_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "COURSE" (
"id" serial PRIMARY KEY,
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"skill_id" uuid NOT NULL REFERENCES "SKILL"(id),
"name" varchar(100) NOT NULL,
"description" text,
"start_at" timestamp NOT NULL,
"end_at" timestamp NOT NULL,
"max_participants" integer NOT NULL,
"meeting_url" varchar(2048) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "COURSE_BOOKING" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"course_id" integer NOT NULL REFERENCES "COURSE"(id),
"booking_at" timestamp NOT NULL,
"status" varchar(20) NOT NULL,
"join_at" timestamp,
"leave_at" timestamp,
"cancelled_at" timestamp,
"cancellation_reason" varchar(255),
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "BLOG_POST" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"title" varchar(255) NOT NULL,
"content" text NOT NULL,
"featured_image_url" varchar(2048),
"category" varchar(20) NOT NULL,
"spend_minutes" smallint NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"updated_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
CREATE TABLE "COMMENT" (
"id" uuid PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
"blog_post_id" uuid NOT NULL REFERENCES "BLOG_POST"(id),
"user_id" uuid NOT NULL REFERENCES "USER"(id),
"content" text NOT NULL,
"created_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
"updated_at" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
);
Redux 是一個開源的 JavaScript 狀態管理庫,通常與 React 或其他 JavaScript 框架一起使用,來管理應用程式的狀態。它最初是由 Dan Abramov 和 Andrew Clark 於 2015 年開發的,並迅速成為處理應用程式狀態管理的一個熱門工具。Redux 的設計理念是將應用程式的所有狀態儲存在一個單一的、不可變的數據結構中,稱為 store。
May 30, 2025接續昨天的練習,發送請求會收到 response,此時可以透過彈出視窗將登入結果呈現在畫面中給使用者,今天會練習使用 SweetAlert 套件,使用 axios 發送請求並將 response 顯示在 SweetAlert。
May 30, 2025如何檢視標示文件 步驟一:必須先註冊 Figma 服務,如下圖 步驟二:登入後,就可以進行檢視模式 切換點擊元素、拖動模式 點擊元素模式:能點擊每個元素檢視詳細資訊 拖動模式:可以移動視窗範圍 快捷鍵(Windows/Mac)
May 29, 2025React Hook Form 是 React 領域中功能強大且高效的表單處理工具。它的輕量性、簡單性和高度靈活性,使其成為構建現代表單的首選解決方案。開發者可以快速構建高性能、可擴展的表單應用。
May 29, 2025or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up