From 5b74083b5f716c6abc4cd317821867cbf8297273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sun, 20 Dec 2020 18:24:04 -0800 Subject: [PATCH] Refactor SQL migrations - Avoid embedding SQL files into binary - Allow more flexible changes by using Go functions --- database/database.go | 51 ++++ database/doc.go | 10 - database/migration.go | 65 ----- database/migrations.go | 430 +++++++++++++++++++++++++++++ database/sql.go | 278 ------------------- database/sql/schema_version_1.sql | 103 ------- database/sql/schema_version_10.sql | 8 - database/sql/schema_version_11.sql | 6 - database/sql/schema_version_12.sql | 1 - database/sql/schema_version_13.sql | 2 - database/sql/schema_version_14.sql | 3 - database/sql/schema_version_15.sql | 1 - database/sql/schema_version_16.sql | 1 - database/sql/schema_version_17.sql | 3 - database/sql/schema_version_18.sql | 1 - database/sql/schema_version_19.sql | 2 - database/sql/schema_version_2.sql | 3 - database/sql/schema_version_20.sql | 3 - database/sql/schema_version_21.sql | 1 - database/sql/schema_version_22.sql | 1 - database/sql/schema_version_23.sql | 1 - database/sql/schema_version_24.sql | 1 - database/sql/schema_version_25.sql | 4 - database/sql/schema_version_26.sql | 3 - database/sql/schema_version_27.sql | 10 - database/sql/schema_version_28.sql | 2 - database/sql/schema_version_29.sql | 1 - database/sql/schema_version_3.sql | 6 - database/sql/schema_version_30.sql | 2 - database/sql/schema_version_31.sql | 1 - database/sql/schema_version_32.sql | 1 - database/sql/schema_version_33.sql | 1 - database/sql/schema_version_34.sql | 1 - database/sql/schema_version_35.sql | 1 - database/sql/schema_version_36.sql | 1 - database/sql/schema_version_37.sql | 1 - database/sql/schema_version_38.sql | 1 - database/sql/schema_version_39.sql | 1 - database/sql/schema_version_4.sql | 2 - database/sql/schema_version_40.sql | 4 - database/sql/schema_version_41.sql | 1 - database/sql/schema_version_42.sql | 2 - database/sql/schema_version_5.sql | 15 - database/sql/schema_version_6.sql | 1 - database/sql/schema_version_7.sql | 1 - database/sql/schema_version_8.sql | 1 - database/sql/schema_version_9.sql | 1 - generate.go | 1 - main.go | 1 - 49 files changed, 481 insertions(+), 561 deletions(-) delete mode 100644 database/doc.go delete mode 100644 database/migration.go create mode 100644 database/migrations.go delete mode 100644 database/sql.go delete mode 100644 database/sql/schema_version_1.sql delete mode 100644 database/sql/schema_version_10.sql delete mode 100644 database/sql/schema_version_11.sql delete mode 100644 database/sql/schema_version_12.sql delete mode 100644 database/sql/schema_version_13.sql delete mode 100644 database/sql/schema_version_14.sql delete mode 100644 database/sql/schema_version_15.sql delete mode 100644 database/sql/schema_version_16.sql delete mode 100644 database/sql/schema_version_17.sql delete mode 100644 database/sql/schema_version_18.sql delete mode 100644 database/sql/schema_version_19.sql delete mode 100644 database/sql/schema_version_2.sql delete mode 100644 database/sql/schema_version_20.sql delete mode 100644 database/sql/schema_version_21.sql delete mode 100644 database/sql/schema_version_22.sql delete mode 100644 database/sql/schema_version_23.sql delete mode 100644 database/sql/schema_version_24.sql delete mode 100644 database/sql/schema_version_25.sql delete mode 100644 database/sql/schema_version_26.sql delete mode 100644 database/sql/schema_version_27.sql delete mode 100644 database/sql/schema_version_28.sql delete mode 100644 database/sql/schema_version_29.sql delete mode 100644 database/sql/schema_version_3.sql delete mode 100644 database/sql/schema_version_30.sql delete mode 100644 database/sql/schema_version_31.sql delete mode 100644 database/sql/schema_version_32.sql delete mode 100644 database/sql/schema_version_33.sql delete mode 100644 database/sql/schema_version_34.sql delete mode 100644 database/sql/schema_version_35.sql delete mode 100644 database/sql/schema_version_36.sql delete mode 100644 database/sql/schema_version_37.sql delete mode 100644 database/sql/schema_version_38.sql delete mode 100644 database/sql/schema_version_39.sql delete mode 100644 database/sql/schema_version_4.sql delete mode 100644 database/sql/schema_version_40.sql delete mode 100644 database/sql/schema_version_41.sql delete mode 100644 database/sql/schema_version_42.sql delete mode 100644 database/sql/schema_version_5.sql delete mode 100644 database/sql/schema_version_6.sql delete mode 100644 database/sql/schema_version_7.sql delete mode 100644 database/sql/schema_version_8.sql delete mode 100644 database/sql/schema_version_9.sql diff --git a/database/database.go b/database/database.go index f5d8a3cd..94461fdf 100644 --- a/database/database.go +++ b/database/database.go @@ -6,9 +6,12 @@ package database // import "miniflux.app/database" import ( "database/sql" + "fmt" // Postgresql driver import _ "github.com/lib/pq" + + "miniflux.app/logger" ) // NewConnectionPool configures the database connection pool. @@ -23,3 +26,51 @@ func NewConnectionPool(dsn string, minConnections, maxConnections int) (*sql.DB, return db, nil } + +// Migrate executes database migrations. +func Migrate(db *sql.DB) { + var currentVersion int + db.QueryRow(`SELECT version FROM schema_version`).Scan(¤tVersion) + + fmt.Println("-> Current schema version:", currentVersion) + fmt.Println("-> Latest schema version:", schemaVersion) + + for version := currentVersion; version < schemaVersion; version++ { + newVersion := version + 1 + fmt.Println("* Migrating to version:", newVersion) + + tx, err := db.Begin() + if err != nil { + logger.Fatal("[Migration v%d] %v", newVersion, err) + } + + if err := migrations[version](tx); err != nil { + tx.Rollback() + logger.Fatal("[Migration v%d] %v", newVersion, err) + } + + if _, err := tx.Exec(`DELETE FROM schema_version`); err != nil { + tx.Rollback() + logger.Fatal("[Migration v%d] %v", newVersion, err) + } + + if _, err := tx.Exec(`INSERT INTO schema_version (version) VALUES ($1)`, newVersion); err != nil { + tx.Rollback() + logger.Fatal("[Migration v%d] %v", newVersion, err) + } + + if err := tx.Commit(); err != nil { + logger.Fatal("[Migration v%d] %v", newVersion, err) + } + } +} + +// IsSchemaUpToDate checks if the database schema is up to date. +func IsSchemaUpToDate(db *sql.DB) error { + var currentVersion int + db.QueryRow(`SELECT version FROM schema_version`).Scan(¤tVersion) + if currentVersion < schemaVersion { + return fmt.Errorf(`the database schema is not up to date: current=v%d expected=v%d`, currentVersion, schemaVersion) + } + return nil +} diff --git a/database/doc.go b/database/doc.go deleted file mode 100644 index 9a2c5fcb..00000000 --- a/database/doc.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2018 Frédéric Guillot. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -/* - -Package database provides functions related to the database connection. - -*/ -package database // import "miniflux.app/database" diff --git a/database/migration.go b/database/migration.go deleted file mode 100644 index 02897236..00000000 --- a/database/migration.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2018 Frédéric Guillot. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package database // import "miniflux.app/database" - -import ( - "database/sql" - "fmt" - "strconv" - - "miniflux.app/logger" -) - -const schemaVersion = 42 - -// Migrate executes database migrations. -func Migrate(db *sql.DB) { - var currentVersion int - db.QueryRow(`SELECT version FROM schema_version`).Scan(¤tVersion) - - fmt.Println("Current schema version:", currentVersion) - fmt.Println("Latest schema version:", schemaVersion) - - for version := currentVersion + 1; version <= schemaVersion; version++ { - fmt.Println("Migrating to version:", version) - - tx, err := db.Begin() - if err != nil { - logger.Fatal("[Migrate] %v", err) - } - - rawSQL := SqlMap["schema_version_"+strconv.Itoa(version)] - // fmt.Println(rawSQL) - _, err = tx.Exec(rawSQL) - if err != nil { - tx.Rollback() - logger.Fatal("[Migrate] %v", err) - } - - if _, err := tx.Exec(`delete from schema_version`); err != nil { - tx.Rollback() - logger.Fatal("[Migrate] %v", err) - } - - if _, err := tx.Exec(`INSERT INTO schema_version (version) VALUES ($1)`, version); err != nil { - tx.Rollback() - logger.Fatal("[Migrate] %v", err) - } - - if err := tx.Commit(); err != nil { - logger.Fatal("[Migrate] %v", err) - } - } -} - -// IsSchemaUpToDate checks if the database schema is up to date. -func IsSchemaUpToDate(db *sql.DB) error { - var currentVersion int - db.QueryRow(`SELECT version FROM schema_version`).Scan(¤tVersion) - if currentVersion != schemaVersion { - return fmt.Errorf(`the database schema is not up to date: current=v%d expected=v%d`, currentVersion, schemaVersion) - } - return nil -} diff --git a/database/migrations.go b/database/migrations.go new file mode 100644 index 00000000..01209c65 --- /dev/null +++ b/database/migrations.go @@ -0,0 +1,430 @@ +// Copyright 2020 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package database // import "miniflux.app/database" + +import "database/sql" + +var schemaVersion = len(migrations) + +var migrations = []func(tx *sql.Tx) error{ + func(tx *sql.Tx) (err error) { + sql := ` + CREATE TABLE schema_version ( + version text not null + ); + + CREATE TABLE users ( + id serial not null, + username text not null unique, + password text, + is_admin bool default 'f', + language text default 'en_US', + timezone text default 'UTC', + theme text default 'default', + last_login_at timestamp with time zone, + primary key (id) + ); + + CREATE TABLE sessions ( + id serial not null, + user_id int not null, + token text not null unique, + created_at timestamp with time zone default now(), + user_agent text, + ip text, + primary key (id), + unique (user_id, token), + foreign key (user_id) references users(id) on delete cascade + ); + + CREATE TABLE categories ( + id serial not null, + user_id int not null, + title text not null, + primary key (id), + unique (user_id, title), + foreign key (user_id) references users(id) on delete cascade + ); + + CREATE TABLE feeds ( + id bigserial not null, + user_id int not null, + category_id int not null, + title text not null, + feed_url text not null, + site_url text not null, + checked_at timestamp with time zone default now(), + etag_header text default '', + last_modified_header text default '', + parsing_error_msg text default '', + parsing_error_count int default 0, + primary key (id), + unique (user_id, feed_url), + foreign key (user_id) references users(id) on delete cascade, + foreign key (category_id) references categories(id) on delete cascade + ); + + CREATE TYPE entry_status as enum('unread', 'read', 'removed'); + + CREATE TABLE entries ( + id bigserial not null, + user_id int not null, + feed_id bigint not null, + hash text not null, + published_at timestamp with time zone not null, + title text not null, + url text not null, + author text, + content text, + status entry_status default 'unread', + primary key (id), + unique (feed_id, hash), + foreign key (user_id) references users(id) on delete cascade, + foreign key (feed_id) references feeds(id) on delete cascade + ); + + CREATE INDEX entries_feed_idx on entries using btree(feed_id); + + CREATE TABLE enclosures ( + id bigserial not null, + user_id int not null, + entry_id bigint not null, + url text not null, + size int default 0, + mime_type text default '', + primary key (id), + foreign key (user_id) references users(id) on delete cascade, + foreign key (entry_id) references entries(id) on delete cascade + ); + + CREATE TABLE icons ( + id bigserial not null, + hash text not null unique, + mime_type text not null, + content bytea not null, + primary key (id) + ); + + CREATE TABLE feed_icons ( + feed_id bigint not null, + icon_id bigint not null, + primary key(feed_id, icon_id), + foreign key (feed_id) references feeds(id) on delete cascade, + foreign key (icon_id) references icons(id) on delete cascade + ); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE EXTENSION IF NOT EXISTS hstore; + ALTER TABLE users ADD COLUMN extra hstore; + CREATE INDEX users_extra_idx ON users using gin(extra); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE TABLE tokens ( + id text not null, + value text not null, + created_at timestamp with time zone not null default now(), + primary key(id, value) + ); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE TYPE entry_sorting_direction AS enum('asc', 'desc'); + ALTER TABLE users ADD COLUMN entry_direction entry_sorting_direction default 'asc'; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE TABLE integrations ( + user_id int not null, + pinboard_enabled bool default 'f', + pinboard_token text default '', + pinboard_tags text default 'miniflux', + pinboard_mark_as_unread bool default 'f', + instapaper_enabled bool default 'f', + instapaper_username text default '', + instapaper_password text default '', + fever_enabled bool default 'f', + fever_username text default '', + fever_password text default '', + fever_token text default '', + primary key(user_id) + ); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN scraper_rules text default ''` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN rewrite_rules text default ''` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN crawler boolean default 'f'` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE sessions rename to user_sessions` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + DROP TABLE tokens; + + CREATE TABLE sessions ( + id text not null, + data jsonb not null, + created_at timestamp with time zone not null default now(), + primary key(id) + ); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE integrations ADD COLUMN wallabag_enabled bool default 'f'; + ALTER TABLE integrations ADD COLUMN wallabag_url text default ''; + ALTER TABLE integrations ADD COLUMN wallabag_client_id text default ''; + ALTER TABLE integrations ADD COLUMN wallabag_client_secret text default ''; + ALTER TABLE integrations ADD COLUMN wallabag_username text default ''; + ALTER TABLE integrations ADD COLUMN wallabag_password text default ''; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE entries ADD COLUMN starred bool default 'f'` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE INDEX entries_user_status_idx ON entries(user_id, status); + CREATE INDEX feeds_user_category_idx ON feeds(user_id, category_id); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE integrations ADD COLUMN nunux_keeper_enabled bool default 'f'; + ALTER TABLE integrations ADD COLUMN nunux_keeper_url text default ''; + ALTER TABLE integrations ADD COLUMN nunux_keeper_api_key text default ''; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE enclosures ALTER COLUMN size SET DATA TYPE bigint` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE entries ADD COLUMN comments_url text default ''` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE integrations ADD COLUMN pocket_enabled bool default 'f'; + ALTER TABLE integrations ADD COLUMN pocket_access_token text default ''; + ALTER TABLE integrations ADD COLUMN pocket_consumer_key text default ''; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE user_sessions ALTER COLUMN ip SET DATA TYPE inet using ip::inet; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE feeds ADD COLUMN username text default ''; + ALTER TABLE feeds ADD COLUMN password text default ''; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE entries ADD COLUMN document_vectors tsvector; + UPDATE entries SET document_vectors = to_tsvector(substring(title || ' ' || coalesce(content, '') for 1000000)); + CREATE INDEX document_vectors_idx ON entries USING gin(document_vectors); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN user_agent text default ''` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + UPDATE + entries + SET + document_vectors = setweight(to_tsvector(substring(coalesce(title, '') for 1000000)), 'A') || setweight(to_tsvector(substring(coalesce(content, '') for 1000000)), 'B') + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE users ADD COLUMN keyboard_shortcuts boolean default 't'` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN disabled boolean default 'f';` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE users ALTER COLUMN theme SET DEFAULT 'light_serif'; + UPDATE users SET theme='light_serif' WHERE theme='default'; + UPDATE users SET theme='light_sans_serif' WHERE theme='sansserif'; + UPDATE users SET theme='dark_serif' WHERE theme='black'; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE entries ADD COLUMN changed_at timestamp with time zone; + UPDATE entries SET changed_at = published_at; + ALTER TABLE entries ALTER COLUMN changed_at SET not null; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + CREATE TABLE api_keys ( + id serial not null, + user_id int not null references users(id) on delete cascade, + token text not null unique, + description text not null, + last_used_at timestamp with time zone, + created_at timestamp with time zone default now(), + primary key(id), + unique (user_id, description) + ); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE entries ADD COLUMN share_code text not null default ''; + CREATE UNIQUE INDEX entries_share_code_idx ON entries USING btree(share_code) WHERE share_code <> ''; + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `CREATE INDEX enclosures_user_entry_url_idx ON enclosures(user_id, entry_id, md5(url))` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE feeds ADD COLUMN next_check_at timestamp with time zone default now(); + CREATE INDEX entries_user_feed_idx ON entries (user_id, feed_id); + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN ignore_http_cache bool default false` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE users ADD COLUMN entries_per_page int default 100` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE users ADD COLUMN show_reading_time boolean default 't'` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `CREATE INDEX entries_id_user_status_idx ON entries USING btree (id, user_id, status)` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE feeds ADD COLUMN fetch_via_proxy bool default false` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `CREATE INDEX entries_feed_id_status_hash_idx ON entries USING btree (feed_id, status, hash)` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `CREATE INDEX entries_user_id_status_starred_idx ON entries (user_id, status, starred)` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE users ADD COLUMN entry_swipe boolean default 't'` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE integrations DROP COLUMN fever_password` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE feeds + ADD COLUMN blocklist_rules text not null default '', + ADD COLUMN keeplist_rules text not null default '' + ` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := `ALTER TABLE entries ADD COLUMN reading_time int not null default 0` + _, err = tx.Exec(sql) + return err + }, + func(tx *sql.Tx) (err error) { + sql := ` + ALTER TABLE entries ADD COLUMN created_at timestamp with time zone not null default now(); + UPDATE entries SET created_at = published_at; + ` + _, err = tx.Exec(sql) + return err + }, +} diff --git a/database/sql.go b/database/sql.go deleted file mode 100644 index 4800b896..00000000 --- a/database/sql.go +++ /dev/null @@ -1,278 +0,0 @@ -// Code generated by go generate; DO NOT EDIT. - -package database // import "miniflux.app/database" - -var SqlMap = map[string]string{ - "schema_version_1": `create table schema_version ( - version text not null -); - -create table users ( - id serial not null, - username text not null unique, - password text, - is_admin bool default 'f', - language text default 'en_US', - timezone text default 'UTC', - theme text default 'default', - last_login_at timestamp with time zone, - primary key (id) -); - -create table sessions ( - id serial not null, - user_id int not null, - token text not null unique, - created_at timestamp with time zone default now(), - user_agent text, - ip text, - primary key (id), - unique (user_id, token), - foreign key (user_id) references users(id) on delete cascade -); - -create table categories ( - id serial not null, - user_id int not null, - title text not null, - primary key (id), - unique (user_id, title), - foreign key (user_id) references users(id) on delete cascade -); - -create table feeds ( - id bigserial not null, - user_id int not null, - category_id int not null, - title text not null, - feed_url text not null, - site_url text not null, - checked_at timestamp with time zone default now(), - etag_header text default '', - last_modified_header text default '', - parsing_error_msg text default '', - parsing_error_count int default 0, - primary key (id), - unique (user_id, feed_url), - foreign key (user_id) references users(id) on delete cascade, - foreign key (category_id) references categories(id) on delete cascade -); - -create type entry_status as enum('unread', 'read', 'removed'); - -create table entries ( - id bigserial not null, - user_id int not null, - feed_id bigint not null, - hash text not null, - published_at timestamp with time zone not null, - title text not null, - url text not null, - author text, - content text, - status entry_status default 'unread', - primary key (id), - unique (feed_id, hash), - foreign key (user_id) references users(id) on delete cascade, - foreign key (feed_id) references feeds(id) on delete cascade -); - -create index entries_feed_idx on entries using btree(feed_id); - -create table enclosures ( - id bigserial not null, - user_id int not null, - entry_id bigint not null, - url text not null, - size int default 0, - mime_type text default '', - primary key (id), - foreign key (user_id) references users(id) on delete cascade, - foreign key (entry_id) references entries(id) on delete cascade -); - -create table icons ( - id bigserial not null, - hash text not null unique, - mime_type text not null, - content bytea not null, - primary key (id) -); - -create table feed_icons ( - feed_id bigint not null, - icon_id bigint not null, - primary key(feed_id, icon_id), - foreign key (feed_id) references feeds(id) on delete cascade, - foreign key (icon_id) references icons(id) on delete cascade -); -`, - "schema_version_10": `drop table tokens; - -create table sessions ( - id text not null, - data jsonb not null, - created_at timestamp with time zone not null default now(), - primary key(id) -);`, - "schema_version_11": `alter table integrations add column wallabag_enabled bool default 'f'; -alter table integrations add column wallabag_url text default ''; -alter table integrations add column wallabag_client_id text default ''; -alter table integrations add column wallabag_client_secret text default ''; -alter table integrations add column wallabag_username text default ''; -alter table integrations add column wallabag_password text default '';`, - "schema_version_12": `alter table entries add column starred bool default 'f';`, - "schema_version_13": `create index entries_user_status_idx on entries(user_id, status); -create index feeds_user_category_idx on feeds(user_id, category_id); -`, - "schema_version_14": `alter table integrations add column nunux_keeper_enabled bool default 'f'; -alter table integrations add column nunux_keeper_url text default ''; -alter table integrations add column nunux_keeper_api_key text default '';`, - "schema_version_15": `alter table enclosures alter column size set data type bigint;`, - "schema_version_16": `alter table entries add column comments_url text default '';`, - "schema_version_17": `alter table integrations add column pocket_enabled bool default 'f'; -alter table integrations add column pocket_access_token text default ''; -alter table integrations add column pocket_consumer_key text default ''; -`, - "schema_version_18": `alter table user_sessions alter column ip set data type inet using ip::inet;`, - "schema_version_19": `alter table feeds add column username text default ''; -alter table feeds add column password text default '';`, - "schema_version_2": `create extension if not exists hstore; -alter table users add column extra hstore; -create index users_extra_idx on users using gin(extra); -`, - "schema_version_20": `alter table entries add column document_vectors tsvector; -update entries set document_vectors = to_tsvector(substring(title || ' ' || coalesce(content, '') for 1000000)); -create index document_vectors_idx on entries using gin(document_vectors);`, - "schema_version_21": `alter table feeds add column user_agent text default '';`, - "schema_version_22": `update entries set document_vectors = setweight(to_tsvector(substring(coalesce(title, '') for 1000000)), 'A') || setweight(to_tsvector(substring(coalesce(content, '') for 1000000)), 'B');`, - "schema_version_23": `alter table users add column keyboard_shortcuts boolean default 't';`, - "schema_version_24": `alter table feeds add column disabled boolean default 'f';`, - "schema_version_25": `ALTER TABLE users ALTER COLUMN theme SET DEFAULT 'light_serif'; -UPDATE users SET theme='light_serif' WHERE theme='default'; -UPDATE users SET theme='light_sans_serif' WHERE theme='sansserif'; -UPDATE users SET theme='dark_serif' WHERE theme='black'; -`, - "schema_version_26": `alter table entries add column changed_at timestamp with time zone; -update entries set changed_at = published_at; -alter table entries alter column changed_at set not null; -`, - "schema_version_27": `create table api_keys ( - id serial not null, - user_id int not null references users(id) on delete cascade, - token text not null unique, - description text not null, - last_used_at timestamp with time zone, - created_at timestamp with time zone default now(), - primary key(id), - unique (user_id, description) -); -`, - "schema_version_28": `alter table entries add column share_code text not null default ''; -create unique index entries_share_code_idx on entries using btree(share_code) where share_code <> ''; -`, - "schema_version_29": `create index enclosures_user_entry_url_idx on enclosures(user_id, entry_id, md5(url)); -`, - "schema_version_3": `create table tokens ( - id text not null, - value text not null, - created_at timestamp with time zone not null default now(), - primary key(id, value) -);`, - "schema_version_30": `alter table feeds add column next_check_at timestamp with time zone default now(); -create index entries_user_feed_idx on entries (user_id, feed_id); -`, - "schema_version_31": `alter table feeds add column ignore_http_cache bool default false;`, - "schema_version_32": `alter table users add column entries_per_page int default 100; -`, - "schema_version_33": `alter table users add column show_reading_time boolean default 't';`, - "schema_version_34": `CREATE INDEX entries_id_user_status_idx ON entries USING btree (id, user_id, status);`, - "schema_version_35": `alter table feeds add column fetch_via_proxy bool default false; -`, - "schema_version_36": `CREATE INDEX entries_feed_id_status_hash_idx ON entries USING btree (feed_id, status, hash);`, - "schema_version_37": `CREATE INDEX entries_user_id_status_starred_idx ON entries (user_id, status, starred);`, - "schema_version_38": `alter table users add column entry_swipe boolean default 't'; -`, - "schema_version_39": `ALTER TABLE integrations DROP COLUMN fever_password; -`, - "schema_version_4": `create type entry_sorting_direction as enum('asc', 'desc'); -alter table users add column entry_direction entry_sorting_direction default 'asc'; -`, - "schema_version_40": `alter table feeds - add column blocklist_rules text not null default '', - add column keeplist_rules text not null default '' -; -`, - "schema_version_41": `alter table entries add column reading_time int not null default 0;`, - "schema_version_42": `alter table entries add column created_at timestamp with time zone not null default now(); -update entries set created_at = published_at; -`, - "schema_version_5": `create table integrations ( - user_id int not null, - pinboard_enabled bool default 'f', - pinboard_token text default '', - pinboard_tags text default 'miniflux', - pinboard_mark_as_unread bool default 'f', - instapaper_enabled bool default 'f', - instapaper_username text default '', - instapaper_password text default '', - fever_enabled bool default 'f', - fever_username text default '', - fever_password text default '', - fever_token text default '', - primary key(user_id) -) -`, - "schema_version_6": `alter table feeds add column scraper_rules text default ''; -`, - "schema_version_7": `alter table feeds add column rewrite_rules text default ''; -`, - "schema_version_8": `alter table feeds add column crawler boolean default 'f'; -`, - "schema_version_9": `alter table sessions rename to user_sessions;`, -} - -var SqlMapChecksums = map[string]string{ - "schema_version_1": "00b2fa9e945565625c93ef9d4242a8b6583dc3cd7edf38d2fc95c0f3f7b926ae", - "schema_version_10": "8faf15ddeff7c8cc305e66218face11ed92b97df2bdc2d0d7944d61441656795", - "schema_version_11": "dc5bbc302e01e425b49c48ddcd8e29e3ab2bb8e73a6cd1858a6ba9fbec0b5243", - "schema_version_12": "a95abab6cdf64811fc744abd37457e2928939d999c5ef00d2bdd9398e16f32fb", - "schema_version_13": "9073fae1e796936f4a43a8120ebdb4218442fe7d346ace6387556a357c2d7edf", - "schema_version_14": "4622e42c4a5a88b6fe1e61f3d367b295968f7260ab5b96481760775ba9f9e1fe", - "schema_version_15": "13ff91462bdf4cda5a94a4c7a09f757761b0f2c32b4be713ba4786a4837750e4", - "schema_version_16": "9d006faca62fd7ab787f64aef0e0a5933d142466ec4cab0e096bb920d2797e34", - "schema_version_17": "b9f15d6217275fedcf6d948dd85ebe978b869bf37f42a86fd5b50a51919fa0e1", - "schema_version_18": "c0ec24847612c7f2dc326cf735baffba79391a56aedd73292371a39f38724a71", - "schema_version_19": "a83f77b41cc213d282805a5b518f15abbf96331599119f0ef4aca4be037add7b", - "schema_version_2": "e8e9ff32478df04fcddad10a34cba2e8bb1e67e7977b5bd6cdc4c31ec94282b4", - "schema_version_20": "5d414c0cfc0da2863c641079afa58b7ff42dccb0f0e01c822ad435c3e3aa9201", - "schema_version_21": "77da01ee38918ff4fe33985fbb20ed3276a717a7584c2ca9ebcf4d4ab6cb6910", - "schema_version_22": "51ed5fbcae9877e57274511f0ef8c61d254ebd78dfbcbc043a2acd30f4c93ca3", - "schema_version_23": "cb3512d328436447f114e305048c0daa8af7505cfe5eab02778b0de1156081b2", - "schema_version_24": "1224754c5b9c6b4038599852bbe72656d21b09cb018d3970bd7c00f0019845bf", - "schema_version_25": "5262d2d4c88d637b6603a1fcd4f68ad257bd59bd1adf89c58a18ee87b12050d7", - "schema_version_26": "64f14add40691f18f514ac0eed10cd9b19c83a35e5c3d8e0bce667e0ceca9094", - "schema_version_27": "4235396b37fd7f52ff6f7526416042bb1649701233e2d99f0bcd583834a0a967", - "schema_version_28": "a64b5ba0b37fe3f209617b7d0e4dd05018d2b8362d2c9c528ba8cce19b77e326", - "schema_version_29": "527403d951d025b387baf7b1ab80c014752c5429cc0b9851aeb34b7716cf2c68", - "schema_version_3": "a54745dbc1c51c000f74d4e5068f1e2f43e83309f023415b1749a47d5c1e0f12", - "schema_version_30": "3ec48a9b2e7a0fc32c85f31652f723565c34213f5f2d7e5e5076aad8f0b40d23", - "schema_version_31": "9290ef295731b03ddfe32dcaded0be70d41b63572420ad379cf2874a9b54581c", - "schema_version_32": "5b4de8dd2d7e3c6ae4150e0e3931df2ee989f2c667145bd67294e5a5f3fae456", - "schema_version_33": "bf38514efeb6c12511f41b1cc484f92722240b0a6ae874c32a958dfea3433d02", - "schema_version_34": "1a3e036f652fc98b7564a27013f04e1eb36dd0d68893c723168f134dc1065822", - "schema_version_35": "162a55df78eed4b9c9c141878132d5f1d97944b96f35a79e38f55716cdd6b3d2", - "schema_version_36": "8164be7818268ad3d4bdcad03a7868b58e32b27cde9b4f056cd82f7b182a0722", - "schema_version_37": "fc9eb1b452341664ddf24c1a9cf01502ac2578136e54a4853081652959285cb9", - "schema_version_38": "e91d2f4075ceb7b8a16a25f350f36dee12cfd1ad86b8b6414c4cf2e9a003358c", - "schema_version_39": "b0f90b97502921d4681a07c64d180a91a0b4ccac7d3c1dbe30519ad6f1bf1737", - "schema_version_4": "216ea3a7d3e1704e40c797b5dc47456517c27dbb6ca98bf88812f4f63d74b5d9", - "schema_version_40": "6a8fec92399f853ed6817aff4cfa43255dce4c19afad796e41519d09de62105e", - "schema_version_41": "128e118ce61267ea1f6ae03b63a6d4734eae87e520b00e309ad083f1f6afdfe5", - "schema_version_42": "3d0cd422c6d9d13e7a619a8dbf081e17750881e0ae9ae380475b09d37ada9e33", - "schema_version_5": "46397e2f5f2c82116786127e9f6a403e975b14d2ca7b652a48cd1ba843e6a27c", - "schema_version_6": "9d05b4fb223f0e60efc716add5048b0ca9c37511cf2041721e20505d6d798ce4", - "schema_version_7": "33f298c9aa30d6de3ca28e1270df51c2884d7596f1283a75716e2aeb634cd05c", - "schema_version_8": "9922073fc4032d8922617ec6a6a07ae8d4817846c138760fb96cb5608ab83bfc", - "schema_version_9": "de5ba954752fe808a993feef5bf0c6f808e0a4ced5379de8bec8342678150892", -} diff --git a/database/sql/schema_version_1.sql b/database/sql/schema_version_1.sql deleted file mode 100644 index cb7c2138..00000000 --- a/database/sql/schema_version_1.sql +++ /dev/null @@ -1,103 +0,0 @@ -create table schema_version ( - version text not null -); - -create table users ( - id serial not null, - username text not null unique, - password text, - is_admin bool default 'f', - language text default 'en_US', - timezone text default 'UTC', - theme text default 'default', - last_login_at timestamp with time zone, - primary key (id) -); - -create table sessions ( - id serial not null, - user_id int not null, - token text not null unique, - created_at timestamp with time zone default now(), - user_agent text, - ip text, - primary key (id), - unique (user_id, token), - foreign key (user_id) references users(id) on delete cascade -); - -create table categories ( - id serial not null, - user_id int not null, - title text not null, - primary key (id), - unique (user_id, title), - foreign key (user_id) references users(id) on delete cascade -); - -create table feeds ( - id bigserial not null, - user_id int not null, - category_id int not null, - title text not null, - feed_url text not null, - site_url text not null, - checked_at timestamp with time zone default now(), - etag_header text default '', - last_modified_header text default '', - parsing_error_msg text default '', - parsing_error_count int default 0, - primary key (id), - unique (user_id, feed_url), - foreign key (user_id) references users(id) on delete cascade, - foreign key (category_id) references categories(id) on delete cascade -); - -create type entry_status as enum('unread', 'read', 'removed'); - -create table entries ( - id bigserial not null, - user_id int not null, - feed_id bigint not null, - hash text not null, - published_at timestamp with time zone not null, - title text not null, - url text not null, - author text, - content text, - status entry_status default 'unread', - primary key (id), - unique (feed_id, hash), - foreign key (user_id) references users(id) on delete cascade, - foreign key (feed_id) references feeds(id) on delete cascade -); - -create index entries_feed_idx on entries using btree(feed_id); - -create table enclosures ( - id bigserial not null, - user_id int not null, - entry_id bigint not null, - url text not null, - size int default 0, - mime_type text default '', - primary key (id), - foreign key (user_id) references users(id) on delete cascade, - foreign key (entry_id) references entries(id) on delete cascade -); - -create table icons ( - id bigserial not null, - hash text not null unique, - mime_type text not null, - content bytea not null, - primary key (id) -); - -create table feed_icons ( - feed_id bigint not null, - icon_id bigint not null, - primary key(feed_id, icon_id), - foreign key (feed_id) references feeds(id) on delete cascade, - foreign key (icon_id) references icons(id) on delete cascade -); diff --git a/database/sql/schema_version_10.sql b/database/sql/schema_version_10.sql deleted file mode 100644 index abd26d87..00000000 --- a/database/sql/schema_version_10.sql +++ /dev/null @@ -1,8 +0,0 @@ -drop table tokens; - -create table sessions ( - id text not null, - data jsonb not null, - created_at timestamp with time zone not null default now(), - primary key(id) -); \ No newline at end of file diff --git a/database/sql/schema_version_11.sql b/database/sql/schema_version_11.sql deleted file mode 100644 index 79f08d78..00000000 --- a/database/sql/schema_version_11.sql +++ /dev/null @@ -1,6 +0,0 @@ -alter table integrations add column wallabag_enabled bool default 'f'; -alter table integrations add column wallabag_url text default ''; -alter table integrations add column wallabag_client_id text default ''; -alter table integrations add column wallabag_client_secret text default ''; -alter table integrations add column wallabag_username text default ''; -alter table integrations add column wallabag_password text default ''; \ No newline at end of file diff --git a/database/sql/schema_version_12.sql b/database/sql/schema_version_12.sql deleted file mode 100644 index 34bc9fd5..00000000 --- a/database/sql/schema_version_12.sql +++ /dev/null @@ -1 +0,0 @@ -alter table entries add column starred bool default 'f'; \ No newline at end of file diff --git a/database/sql/schema_version_13.sql b/database/sql/schema_version_13.sql deleted file mode 100644 index c2b5df7f..00000000 --- a/database/sql/schema_version_13.sql +++ /dev/null @@ -1,2 +0,0 @@ -create index entries_user_status_idx on entries(user_id, status); -create index feeds_user_category_idx on feeds(user_id, category_id); diff --git a/database/sql/schema_version_14.sql b/database/sql/schema_version_14.sql deleted file mode 100644 index bfd7ca25..00000000 --- a/database/sql/schema_version_14.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table integrations add column nunux_keeper_enabled bool default 'f'; -alter table integrations add column nunux_keeper_url text default ''; -alter table integrations add column nunux_keeper_api_key text default ''; \ No newline at end of file diff --git a/database/sql/schema_version_15.sql b/database/sql/schema_version_15.sql deleted file mode 100644 index b5cb3862..00000000 --- a/database/sql/schema_version_15.sql +++ /dev/null @@ -1 +0,0 @@ -alter table enclosures alter column size set data type bigint; \ No newline at end of file diff --git a/database/sql/schema_version_16.sql b/database/sql/schema_version_16.sql deleted file mode 100644 index e4f6d231..00000000 --- a/database/sql/schema_version_16.sql +++ /dev/null @@ -1 +0,0 @@ -alter table entries add column comments_url text default ''; \ No newline at end of file diff --git a/database/sql/schema_version_17.sql b/database/sql/schema_version_17.sql deleted file mode 100644 index b4cc8487..00000000 --- a/database/sql/schema_version_17.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table integrations add column pocket_enabled bool default 'f'; -alter table integrations add column pocket_access_token text default ''; -alter table integrations add column pocket_consumer_key text default ''; diff --git a/database/sql/schema_version_18.sql b/database/sql/schema_version_18.sql deleted file mode 100644 index 4b36904a..00000000 --- a/database/sql/schema_version_18.sql +++ /dev/null @@ -1 +0,0 @@ -alter table user_sessions alter column ip set data type inet using ip::inet; \ No newline at end of file diff --git a/database/sql/schema_version_19.sql b/database/sql/schema_version_19.sql deleted file mode 100644 index 130ae08c..00000000 --- a/database/sql/schema_version_19.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table feeds add column username text default ''; -alter table feeds add column password text default ''; \ No newline at end of file diff --git a/database/sql/schema_version_2.sql b/database/sql/schema_version_2.sql deleted file mode 100644 index d88b4041..00000000 --- a/database/sql/schema_version_2.sql +++ /dev/null @@ -1,3 +0,0 @@ -create extension if not exists hstore; -alter table users add column extra hstore; -create index users_extra_idx on users using gin(extra); diff --git a/database/sql/schema_version_20.sql b/database/sql/schema_version_20.sql deleted file mode 100644 index 18461b89..00000000 --- a/database/sql/schema_version_20.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table entries add column document_vectors tsvector; -update entries set document_vectors = to_tsvector(substring(title || ' ' || coalesce(content, '') for 1000000)); -create index document_vectors_idx on entries using gin(document_vectors); \ No newline at end of file diff --git a/database/sql/schema_version_21.sql b/database/sql/schema_version_21.sql deleted file mode 100644 index 2c96d764..00000000 --- a/database/sql/schema_version_21.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column user_agent text default ''; \ No newline at end of file diff --git a/database/sql/schema_version_22.sql b/database/sql/schema_version_22.sql deleted file mode 100644 index 1b51e8a1..00000000 --- a/database/sql/schema_version_22.sql +++ /dev/null @@ -1 +0,0 @@ -update entries set document_vectors = setweight(to_tsvector(substring(coalesce(title, '') for 1000000)), 'A') || setweight(to_tsvector(substring(coalesce(content, '') for 1000000)), 'B'); \ No newline at end of file diff --git a/database/sql/schema_version_23.sql b/database/sql/schema_version_23.sql deleted file mode 100644 index 2afb9622..00000000 --- a/database/sql/schema_version_23.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users add column keyboard_shortcuts boolean default 't'; \ No newline at end of file diff --git a/database/sql/schema_version_24.sql b/database/sql/schema_version_24.sql deleted file mode 100644 index be434508..00000000 --- a/database/sql/schema_version_24.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column disabled boolean default 'f'; \ No newline at end of file diff --git a/database/sql/schema_version_25.sql b/database/sql/schema_version_25.sql deleted file mode 100644 index e0b63423..00000000 --- a/database/sql/schema_version_25.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE users ALTER COLUMN theme SET DEFAULT 'light_serif'; -UPDATE users SET theme='light_serif' WHERE theme='default'; -UPDATE users SET theme='light_sans_serif' WHERE theme='sansserif'; -UPDATE users SET theme='dark_serif' WHERE theme='black'; diff --git a/database/sql/schema_version_26.sql b/database/sql/schema_version_26.sql deleted file mode 100644 index d091e611..00000000 --- a/database/sql/schema_version_26.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table entries add column changed_at timestamp with time zone; -update entries set changed_at = published_at; -alter table entries alter column changed_at set not null; diff --git a/database/sql/schema_version_27.sql b/database/sql/schema_version_27.sql deleted file mode 100644 index ea4f3d08..00000000 --- a/database/sql/schema_version_27.sql +++ /dev/null @@ -1,10 +0,0 @@ -create table api_keys ( - id serial not null, - user_id int not null references users(id) on delete cascade, - token text not null unique, - description text not null, - last_used_at timestamp with time zone, - created_at timestamp with time zone default now(), - primary key(id), - unique (user_id, description) -); diff --git a/database/sql/schema_version_28.sql b/database/sql/schema_version_28.sql deleted file mode 100644 index fed34cfa..00000000 --- a/database/sql/schema_version_28.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table entries add column share_code text not null default ''; -create unique index entries_share_code_idx on entries using btree(share_code) where share_code <> ''; diff --git a/database/sql/schema_version_29.sql b/database/sql/schema_version_29.sql deleted file mode 100644 index 5d7ee8b6..00000000 --- a/database/sql/schema_version_29.sql +++ /dev/null @@ -1 +0,0 @@ -create index enclosures_user_entry_url_idx on enclosures(user_id, entry_id, md5(url)); diff --git a/database/sql/schema_version_3.sql b/database/sql/schema_version_3.sql deleted file mode 100644 index d58e35d9..00000000 --- a/database/sql/schema_version_3.sql +++ /dev/null @@ -1,6 +0,0 @@ -create table tokens ( - id text not null, - value text not null, - created_at timestamp with time zone not null default now(), - primary key(id, value) -); \ No newline at end of file diff --git a/database/sql/schema_version_30.sql b/database/sql/schema_version_30.sql deleted file mode 100644 index 686b3fdb..00000000 --- a/database/sql/schema_version_30.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table feeds add column next_check_at timestamp with time zone default now(); -create index entries_user_feed_idx on entries (user_id, feed_id); diff --git a/database/sql/schema_version_31.sql b/database/sql/schema_version_31.sql deleted file mode 100644 index eca9f243..00000000 --- a/database/sql/schema_version_31.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column ignore_http_cache bool default false; \ No newline at end of file diff --git a/database/sql/schema_version_32.sql b/database/sql/schema_version_32.sql deleted file mode 100644 index 3ab2ec52..00000000 --- a/database/sql/schema_version_32.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users add column entries_per_page int default 100; diff --git a/database/sql/schema_version_33.sql b/database/sql/schema_version_33.sql deleted file mode 100644 index c13d6491..00000000 --- a/database/sql/schema_version_33.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users add column show_reading_time boolean default 't'; \ No newline at end of file diff --git a/database/sql/schema_version_34.sql b/database/sql/schema_version_34.sql deleted file mode 100644 index 2659b01a..00000000 --- a/database/sql/schema_version_34.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX entries_id_user_status_idx ON entries USING btree (id, user_id, status); \ No newline at end of file diff --git a/database/sql/schema_version_35.sql b/database/sql/schema_version_35.sql deleted file mode 100644 index 50533751..00000000 --- a/database/sql/schema_version_35.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column fetch_via_proxy bool default false; diff --git a/database/sql/schema_version_36.sql b/database/sql/schema_version_36.sql deleted file mode 100644 index 660b5f4f..00000000 --- a/database/sql/schema_version_36.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX entries_feed_id_status_hash_idx ON entries USING btree (feed_id, status, hash); \ No newline at end of file diff --git a/database/sql/schema_version_37.sql b/database/sql/schema_version_37.sql deleted file mode 100644 index 330dab20..00000000 --- a/database/sql/schema_version_37.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX entries_user_id_status_starred_idx ON entries (user_id, status, starred); \ No newline at end of file diff --git a/database/sql/schema_version_38.sql b/database/sql/schema_version_38.sql deleted file mode 100644 index 2527ad60..00000000 --- a/database/sql/schema_version_38.sql +++ /dev/null @@ -1 +0,0 @@ -alter table users add column entry_swipe boolean default 't'; diff --git a/database/sql/schema_version_39.sql b/database/sql/schema_version_39.sql deleted file mode 100644 index a7148f7c..00000000 --- a/database/sql/schema_version_39.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE integrations DROP COLUMN fever_password; diff --git a/database/sql/schema_version_4.sql b/database/sql/schema_version_4.sql deleted file mode 100644 index 988c4865..00000000 --- a/database/sql/schema_version_4.sql +++ /dev/null @@ -1,2 +0,0 @@ -create type entry_sorting_direction as enum('asc', 'desc'); -alter table users add column entry_direction entry_sorting_direction default 'asc'; diff --git a/database/sql/schema_version_40.sql b/database/sql/schema_version_40.sql deleted file mode 100644 index c0b5ce76..00000000 --- a/database/sql/schema_version_40.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table feeds - add column blocklist_rules text not null default '', - add column keeplist_rules text not null default '' -; diff --git a/database/sql/schema_version_41.sql b/database/sql/schema_version_41.sql deleted file mode 100644 index 6b9c43dd..00000000 --- a/database/sql/schema_version_41.sql +++ /dev/null @@ -1 +0,0 @@ -alter table entries add column reading_time int not null default 0; \ No newline at end of file diff --git a/database/sql/schema_version_42.sql b/database/sql/schema_version_42.sql deleted file mode 100644 index b2937475..00000000 --- a/database/sql/schema_version_42.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table entries add column created_at timestamp with time zone not null default now(); -update entries set created_at = published_at; diff --git a/database/sql/schema_version_5.sql b/database/sql/schema_version_5.sql deleted file mode 100644 index dac79374..00000000 --- a/database/sql/schema_version_5.sql +++ /dev/null @@ -1,15 +0,0 @@ -create table integrations ( - user_id int not null, - pinboard_enabled bool default 'f', - pinboard_token text default '', - pinboard_tags text default 'miniflux', - pinboard_mark_as_unread bool default 'f', - instapaper_enabled bool default 'f', - instapaper_username text default '', - instapaper_password text default '', - fever_enabled bool default 'f', - fever_username text default '', - fever_password text default '', - fever_token text default '', - primary key(user_id) -) diff --git a/database/sql/schema_version_6.sql b/database/sql/schema_version_6.sql deleted file mode 100644 index 6f79ca8e..00000000 --- a/database/sql/schema_version_6.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column scraper_rules text default ''; diff --git a/database/sql/schema_version_7.sql b/database/sql/schema_version_7.sql deleted file mode 100644 index f4d2a9ce..00000000 --- a/database/sql/schema_version_7.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column rewrite_rules text default ''; diff --git a/database/sql/schema_version_8.sql b/database/sql/schema_version_8.sql deleted file mode 100644 index d86c29b4..00000000 --- a/database/sql/schema_version_8.sql +++ /dev/null @@ -1 +0,0 @@ -alter table feeds add column crawler boolean default 'f'; diff --git a/database/sql/schema_version_9.sql b/database/sql/schema_version_9.sql deleted file mode 100644 index 77617243..00000000 --- a/database/sql/schema_version_9.sql +++ /dev/null @@ -1 +0,0 @@ -alter table sessions rename to user_sessions; \ No newline at end of file diff --git a/generate.go b/generate.go index 9b0add88..d552d0fe 100644 --- a/generate.go +++ b/generate.go @@ -215,7 +215,6 @@ func main() { generateBinaryBundle("ui/static/bin.go", glob("ui/static/bin/*")) - generateBundle("database/sql.go", "database", "SqlMap", glob("database/sql/*.sql")) generateBundle("template/views.go", "template", "templateViewsMap", glob("template/html/*.html")) generateBundle("template/common.go", "template", "templateCommonMap", glob("template/html/common/*.html")) generateBundle("locale/translations.go", "locale", "translations", glob("locale/translations/*.json")) diff --git a/main.go b/main.go index b56e427a..d079d7e0 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ package main // import "miniflux.app" //go:generate go run generate.go -//go:generate gofmt -s -w database/sql.go //go:generate gofmt -s -w ui/static/css.go //go:generate gofmt -s -w ui/static/bin.go //go:generate gofmt -s -w ui/static/js.go