Submission uploads (lib.uploadRequest.processFile) generate an error: null value in column active violates not-null constraint. This sets a default value on this column of false and columns in the visits table to zero which also have not-null constraints, ensuring errors like these are prevented
This commit is contained in:
parent
defaa2ae0b
commit
9ea77c095f
1 changed files with 11 additions and 0 deletions
|
@ -135,11 +135,22 @@ func RO(db DB) DB {
|
|||
}
|
||||
|
||||
const createSQL = `
|
||||
|
||||
-- Visits default values
|
||||
ALTER TABLE visits ALTER COLUMN downloads SET DEFAULT 0 ;
|
||||
ALTER TABLE visits ALTER COLUMN views SET DEFAULT 0 ;
|
||||
|
||||
|
||||
-- Books default values
|
||||
ALTER TABLE books ALTER COLUMN active SET DEFAULT false ;
|
||||
|
||||
-- Books column indexes
|
||||
CREATE INDEX IF NOT EXISTS books_lang_idx ON books (lang);
|
||||
CREATE INDEX IF NOT EXISTS books_isbn_idx ON books (isbn);
|
||||
CREATE INDEX IF NOT EXISTS books_active_idx ON books (active);
|
||||
|
||||
|
||||
|
||||
-- Books trigram indexes
|
||||
CREATE INDEX IF NOT EXISTS books_title_idx ON books USING GIN (title gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS books_contributor_idx ON books USING GIN (contributor gin_trgm_ops);
|
||||
|
|
Reference in a new issue