mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-26 10:36:23 -07:00
Rename threads column spoilered to is_spoilered for consistency
This commit is contained in:
parent
00fb6a5688
commit
f37dbbc840
9 changed files with 56 additions and 30 deletions
|
@ -194,12 +194,12 @@ func updateMysqlDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *confi
|
|||
}
|
||||
|
||||
// add spoilered column to DBPREFIXthreads
|
||||
dataType, err = common.ColumnType(ctx, db, nil, "spoilered", "DBPREFIXthreads", sqlConfig)
|
||||
dataType, err = common.ColumnType(ctx, db, nil, "is_spoilered", "DBPREFIXthreads", sqlConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dataType == "" {
|
||||
query = `ALTER TABLE DBPREFIXthreads ADD COLUMN spoilered BOOL NOT NULL DEFAULT FALSE`
|
||||
query = `ALTER TABLE DBPREFIXthreads ADD COLUMN is_spoilered BOOL NOT NULL DEFAULT FALSE`
|
||||
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -105,5 +105,17 @@ func updatePostgresDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *co
|
|||
}
|
||||
}
|
||||
|
||||
// add spoilered column to DBPREFIXthreads
|
||||
dataType, err = common.ColumnType(ctx, db, nil, "is_spoilered", "DBPREFIXthreads", sqlConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dataType == "" {
|
||||
query = `ALTER TABLE DBPREFIXthreads ADD COLUMN is_spoilered BOOL NOT NULL DEFAULT FALSE`
|
||||
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -123,5 +123,17 @@ func updateSqliteDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *conf
|
|||
}
|
||||
}
|
||||
|
||||
// add spoilered column to DBPREFIXthreads
|
||||
dataType, err = common.ColumnType(ctx, db, nil, "is_spoilered", "DBPREFIXthreads", sqlConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dataType == "" {
|
||||
query = `ALTER TABLE DBPREFIXthreads ADD COLUMN is_spoilered BOOL NOT NULL DEFAULT FALSE`
|
||||
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -274,16 +274,16 @@ type Staff struct {
|
|||
|
||||
// table: DBPREFIXthreads
|
||||
type Thread struct {
|
||||
ID int // sql: id
|
||||
BoardID int // sql: board_id
|
||||
Locked bool // sql: locked
|
||||
Stickied bool // sql: stickied
|
||||
Anchored bool // sql: anchored
|
||||
Cyclic bool // sql: cyclical
|
||||
Spoilered bool // sql: spoilered
|
||||
LastBump time.Time // sql: last_bump
|
||||
DeletedAt time.Time // sql: deleted_at
|
||||
IsDeleted bool // sql: is_deleted
|
||||
ID int // sql: id
|
||||
BoardID int // sql: board_id
|
||||
Locked bool // sql: locked
|
||||
Stickied bool // sql: stickied
|
||||
Anchored bool // sql: anchored
|
||||
Cyclic bool // sql: cyclical
|
||||
IsSpoilered bool // sql: is_spoilered
|
||||
LastBump time.Time // sql: last_bump
|
||||
DeletedAt time.Time // sql: deleted_at
|
||||
IsDeleted bool // sql: is_deleted
|
||||
}
|
||||
|
||||
// Wordfilter is used for filters that are expected to have a single FilterCondition and a "replace" MatchAction
|
||||
|
|
|
@ -55,7 +55,7 @@ CREATE TABLE DBPREFIXthreads(
|
|||
stickied BOOL NOT NULL DEFAULT FALSE,
|
||||
anchored BOOL NOT NULL DEFAULT FALSE,
|
||||
cyclical BOOL NOT NULL DEFAULT FALSE,
|
||||
spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
is_spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
last_bump TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
is_deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
|
|
|
@ -48,7 +48,7 @@ CREATE TABLE DBPREFIXthreads(
|
|||
stickied BOOL NOT NULL DEFAULT FALSE,
|
||||
anchored BOOL NOT NULL DEFAULT FALSE,
|
||||
cyclical BOOL NOT NULL DEFAULT FALSE,
|
||||
spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
is_spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
last_bump TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
is_deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
|
|
|
@ -48,7 +48,7 @@ CREATE TABLE DBPREFIXthreads(
|
|||
stickied BOOL NOT NULL DEFAULT FALSE,
|
||||
anchored BOOL NOT NULL DEFAULT FALSE,
|
||||
cyclical BOOL NOT NULL DEFAULT FALSE,
|
||||
spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
is_spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
last_bump TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
is_deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
|
|
|
@ -48,7 +48,7 @@ CREATE TABLE DBPREFIXthreads(
|
|||
stickied BOOL NOT NULL DEFAULT FALSE,
|
||||
anchored BOOL NOT NULL DEFAULT FALSE,
|
||||
cyclical BOOL NOT NULL DEFAULT FALSE,
|
||||
spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
is_spoilered BOOL NOT NULL DEFAULT FALSE,
|
||||
last_bump TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
is_deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
|
|
|
@ -18,7 +18,7 @@ DROP VIEW IF EXISTS DBPREFIXv_thread_board_ids;
|
|||
|
||||
-- create views
|
||||
CREATE VIEW DBPREFIXv_thread_board_ids AS
|
||||
SELECT id, board_id from DBPREFIXthreads;
|
||||
SELECT id, board_id, is_spoilered from DBPREFIXthreads;
|
||||
|
||||
CREATE VIEW DBPREFIXv_top_post_thread_ids AS
|
||||
SELECT id, thread_id FROM DBPREFIXposts WHERE is_top_post;
|
||||
|
@ -28,15 +28,16 @@ SELECT p.id AS id, p.thread_id AS thread_id, ip, name, tripcode, is_secure_tripc
|
|||
email, subject, created_on, created_on as last_modified, op.id AS parent_id, t.last_bump as last_bump,
|
||||
message, message_raw, t.board_id,
|
||||
(SELECT dir FROM DBPREFIXboards WHERE id = t.board_id LIMIT 1) AS dir,
|
||||
coalesce(f.original_filename, '') as original_filename,
|
||||
coalesce(f.filename, '') AS filename,
|
||||
coalesce(f.checksum, '') AS checksum,
|
||||
coalesce(f.file_size, 0) AS filesize,
|
||||
coalesce(f.thumbnail_width, 0) AS tw,
|
||||
coalesce(f.thumbnail_height, 0) AS th,
|
||||
coalesce(f.width, 0) AS width,
|
||||
coalesce(f.height, 0) AS height,
|
||||
t.locked, t.stickied, t.cyclical, t.spoilered, flag, country, p.is_deleted
|
||||
COALESCE(f.original_filename, '') as original_filename,
|
||||
COALESCE(f.filename, '') AS filename,
|
||||
COALESCE(f.checksum, '') AS checksum,
|
||||
COALESCE(f.file_size, 0) AS filesize,
|
||||
COALESCE(f.thumbnail_width, 0) AS tw,
|
||||
COALESCE(f.thumbnail_height, 0) AS th,
|
||||
COALESCE(f.width, 0) AS width,
|
||||
COALESCE(f.height, 0) AS height,
|
||||
COALESCE(f.is_spoilered) AS spoiler_file,
|
||||
t.locked, t.stickied, t.cyclical, t.is_spoilered as spoiler_thread, flag, country, p.is_deleted
|
||||
FROM DBPREFIXposts p
|
||||
LEFT JOIN DBPREFIXfiles f ON f.post_id = p.id AND p.is_deleted = FALSE
|
||||
LEFT JOIN DBPREFIXthreads t ON t.id = p.thread_id
|
||||
|
@ -68,12 +69,13 @@ CREATE VIEW DBPREFIXv_front_page_posts AS
|
|||
SELECT DBPREFIXposts.id, DBPREFIXposts.message_raw,
|
||||
(SELECT dir FROM DBPREFIXboards WHERE id = t.board_id) as dir,
|
||||
COALESCE(f.filename, '') as filename, op.id as op_id,
|
||||
COALESCE(f.original_filename, '') as original_filename
|
||||
COALESCE(f.original_filename, '') as original_filename,
|
||||
COALESCE(f.is_spoilered) AS spoiler_file
|
||||
FROM DBPREFIXposts
|
||||
LEFT JOIN DBPREFIXv_thread_board_ids t ON t.id = DBPREFIXposts.thread_id
|
||||
LEFT JOIN (SELECT post_id, filename, original_filename FROM DBPREFIXfiles) f on f.post_id = DBPREFIXposts.id
|
||||
LEFT JOIN DBPREFIXfiles f on f.post_id = DBPREFIXposts.id
|
||||
INNER JOIN DBPREFIXv_top_post_thread_ids op ON op.thread_id = DBPREFIXposts.thread_id
|
||||
WHERE DBPREFIXposts.is_deleted = FALSE;
|
||||
WHERE DBPREFIXposts.is_deleted = FALSE AND t.is_spoilered = FALSE;
|
||||
|
||||
CREATE VIEW DBPREFIXv_front_page_posts_with_file AS
|
||||
SELECT * FROM DBPREFIXv_front_page_posts
|
||||
|
@ -81,7 +83,7 @@ WHERE filename IS NOT NULL AND filename <> '' AND filename <> 'deleted';
|
|||
|
||||
CREATE VIEW DBPREFIXv_upload_info AS
|
||||
SELECT p1.id as id, (SELECT id FROM DBPREFIXposts p2 WHERE p2.is_top_post AND p1.thread_id = p2.thread_id LIMIT 1) AS op,
|
||||
filename, is_spoilered, width, height, thumbnail_width, thumbnail_height
|
||||
filename, f.is_spoilered, width, height, thumbnail_width, thumbnail_height
|
||||
FROM DBPREFIXposts p1
|
||||
JOIN DBPREFIXthreads t ON t.id = p1.thread_id
|
||||
JOIN DBPREFIXboards b ON b.id = t.board_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue