mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2026-03-03 07:00:51 +01:00
Add DB migrations and run them on startup
Enable sqlx "migrate" feature and add SQL migrations to create the database schema: pg_trgm extension, sources, genres, authors, sequences, books, junction tables, annotations, and supporting indexes
This commit is contained in:
12
migrations/20260116092213_create_book_annotations_table.sql
Normal file
12
migrations/20260116092213_create_book_annotations_table.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Create book_annotations table
|
||||
CREATE TABLE IF NOT EXISTS book_annotations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
book INTEGER NOT NULL UNIQUE,
|
||||
title VARCHAR(256) NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
file VARCHAR(256),
|
||||
CONSTRAINT fk_book_annotations_books_id_book FOREIGN KEY (book) REFERENCES books(id)
|
||||
);
|
||||
|
||||
-- Create index for book_annotations
|
||||
CREATE INDEX IF NOT EXISTS book_annotation_book_id ON book_annotations (book);
|
||||
Reference in New Issue
Block a user