Preliminary library-related tables.
This commit is contained in:
parent
c39dc95387
commit
477419ef63
1 changed files with 31 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
);
|
||||
Loading…
Reference in a new issue