Preliminary library-related tables.

This commit is contained in:
Benjamin A. Shelton 2026-11-03 22:41:44 -07:00
commit 477419ef63
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -1,3 +1,5 @@
-- @up
create table library_books (
id integer primary key autoincrement,
isbn integer default 0 not null,
@ -7,4 +9,32 @@ create table library_books (
authors text default '' not null,
meta jsonb default '{}' not null
);
create unique index library_books_isbn_check_idx on library_books(isbn, isbn_check);
create unique index library_books_isbn_check_idx on library_books(isbn, isbn_check);
create table library_checkout (
bookid integer default 0 not null,
-- Checkout user, if available.
userid integer default null,
-- Checkout recipient. This should only be populated if the user ID is not
-- present.
recipient text default '' not null,
checked_out datetime default current_timestamp not null,
returned_at datetime default null,
foreign key (userid) references users(id),
foreign key (bookid) references library_books(id)
);
-- The queue table contains individuals waiting in the queue for a book that is
-- currently loaned out.
create table library_queue(
bookid integer default 0 not null,
userid integer default null,
requester text default '' not null,
foreign key (bookid) references library_books(id),
foreign key (userid) references users(id)
);