generated from phundrak/rust-poem-openapi-template
This commit renames gejdr-crud to georm for an easier name to remember in case I publish `georm` and `georm-macros`. This commit extracts the `Georm` (formerly `Crud`) trait from `gejdr-core` to its dedicated crate `georm` on which gejdr-core now depends. Currently writing tests
27 lines
708 B
SQL
27 lines
708 B
SQL
CREATE SCHEMA IF NOT EXISTS tests;
|
|
|
|
CREATE TABLE tests.authors (
|
|
author_id SERIAL PRIMARY KEY,
|
|
name VARCHAR(100) NOT NULL
|
|
);
|
|
|
|
CREATE TABLE tests.books (
|
|
id SERIAL PRIMARY KEY,
|
|
title VARCHAR(100) NOT NULL,
|
|
author_id INT NOT NULL,
|
|
FOREIGN KEY (author_id) REFERENCES tests.authors(author_id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE tests.genres (
|
|
genre_id SERIAL PRIMARY KEY,
|
|
name VARCHAR(100) NOT NULL
|
|
);
|
|
|
|
CREATE TABLE tests.book_genres (
|
|
book_id INT NOT NULL,
|
|
genre_id INT NOT NULL,
|
|
PRIMARY KEY (book_id, genre_id),
|
|
FOREIGN KEY (book_id) REFERENCES tests.books(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (genre_id) REFERENCES tests.genres(genre_id) ON DELETE CASCADE
|
|
);
|