-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing get_latest_migration_version to handle error when initial tabl…
…e doesnt exist
- Loading branch information
Showing
12 changed files
with
25 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
njord_examples/sqlite/migrations/00000000000000_njord_initial_setup/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
-- Drop tables in reverse order to handle foreign key constraints | ||
|
||
DROP TABLE IF EXISTS order_products; | ||
DROP TABLE IF EXISTS orders; | ||
DROP TABLE IF EXISTS products; | ||
DROP TABLE IF EXISTS users; | ||
DROP TABLE IF EXISTS migration_history; |
37 changes: 5 additions & 32 deletions
37
njord_examples/sqlite/migrations/00000000000000_njord_initial_setup/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,5 @@ | ||
-- users table | ||
CREATE TABLE users ( | ||
user_id INTEGER PRIMARY KEY, | ||
username TEXT NOT NULL, | ||
email TEXT NOT NULL, | ||
address TEXT NOT NULL | ||
); | ||
|
||
-- products table | ||
CREATE TABLE products ( | ||
product_id INTEGER PRIMARY KEY, | ||
name TEXT NOT NULL, | ||
description TEXT NOT NULL, | ||
price REAL NOT NULL, | ||
stock_quantity INTEGER NOT NULL, | ||
category TEXT NOT NULL | ||
); | ||
|
||
-- orders table | ||
CREATE TABLE orders ( | ||
order_id INTEGER PRIMARY KEY, | ||
user_id INTEGER REFERENCES users(user_id), | ||
total_cost REAL NOT NULL, | ||
order_date TEXT NOT NULL | ||
); | ||
|
||
-- order_products table | ||
CREATE TABLE order_products ( | ||
order_id INTEGER REFERENCES orders(order_id), | ||
product_id INTEGER REFERENCES products(product_id), | ||
PRIMARY KEY (order_id, product_id) | ||
); | ||
CREATE TABLE IF NOT EXISTS migration_history ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
version TEXT NOT NULL, | ||
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.