Skip to content

Commit 6c6a1be

Browse files
committed
feat: Add migration scripts🫸🌀✏️📗🐧🐳⬆
1 parent 33b946a commit 6c6a1be

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE Users (
2+
user_id SERIAL PRIMARY KEY,
3+
username VARCHAR(50) UNIQUE NOT NULL,
4+
email VARCHAR(100) UNIQUE NOT NULL,
5+
password VARCHAR(100) NOT NULL,
6+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
7+
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE TABLE Books (
2+
book_id SERIAL PRIMARY KEY,
3+
title VARCHAR(100) NOT NULL,
4+
author VARCHAR(100) NOT NULL,
5+
isbn VARCHAR(20) UNIQUE NOT NULL,
6+
published_date DATE,
7+
genre VARCHAR(50),
8+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
9+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE BookInstances (
2+
instance_id SERIAL PRIMARY KEY,
3+
book_id INT REFERENCES Books(book_id),
4+
status VARCHAR(20) CHECK (status IN ('available', 'checked_out', 'reserved')) NOT NULL,
5+
due_date DATE,
6+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
7+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE Checkouts (
2+
checkout_id SERIAL PRIMARY KEY,
3+
user_id INT REFERENCES Users(user_id),
4+
instance_id INT REFERENCES BookInstances(instance_id),
5+
checkout_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
6+
return_date TIMESTAMP
7+
);

0 commit comments

Comments
 (0)