1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-16 09:56:24 -07:00

Add is_secure_tripcode column to posts and update gochan-migration to add it

This commit is contained in:
Eggbertx 2025-04-06 15:08:46 -07:00
parent ffac903eb5
commit 4c0ce122ad
16 changed files with 182 additions and 90 deletions

View file

@ -32,7 +32,7 @@ func updateMysqlDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *confi
}
var rows *sql.Rows
query = `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = ?`
query = `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_TYPE = 'BASE TABLE'`
rows, err = db.QueryContextSQL(ctx, nil, query, dbName)
if err != nil {
return err
@ -181,5 +181,17 @@ func updateMysqlDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *confi
}
}
// add is_secure_tripcode column to DBPREFIXposts
dataType, err = common.ColumnType(ctx, db, nil, "is_secure_tripcode", "DBPREFIXposts", sqlConfig)
if err != nil {
return err
}
if dataType == "" {
query = `ALTER TABLE DBPREFIXposts ADD COLUMN is_secure_tripcode BOOL NOT NULL DEFAULT FALSE`
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
return err
}
}
return nil
}

View file

@ -93,5 +93,17 @@ func updatePostgresDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *co
}
}
// add is_secure_tripcode column to DBPREFIXposts
dataType, err = common.ColumnType(ctx, db, nil, "is_secure_tripcode", "DBPREFIXposts", sqlConfig)
if err != nil {
return err
}
if dataType == "" {
query = `ALTER TABLE DBPREFIXposts ADD COLUMN is_secure_tripcode BOOL NOT NULL DEFAULT FALSE`
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
return err
}
}
return nil
}

View file

@ -111,5 +111,17 @@ func updateSqliteDB(ctx context.Context, dbu *GCDatabaseUpdater, sqlConfig *conf
}
}
// add is_secure_tripcode column to DBPREFIXposts
dataType, err = common.ColumnType(ctx, db, nil, "is_secure_tripcode", "DBPREFIXposts", sqlConfig)
if err != nil {
return err
}
if dataType == "" {
query = `ALTER TABLE DBPREFIXposts ADD COLUMN is_secure_tripcode BOOL NOT NULL DEFAULT FALSE`
if _, err = db.ExecContextSQL(ctx, nil, query); err != nil {
return err
}
}
return nil
}

View file

@ -97,8 +97,8 @@ func (m *Pre2021Migrator) MigratePosts() error {
for rows.Next() {
var thread migrationPost
if err = rows.Scan(
&thread.oldID, &thread.oldBoardID, &thread.oldParentID, &thread.Name, &thread.Tripcode, &thread.Email,
&thread.Subject, &thread.Message, &thread.MessageRaw, &thread.Password, &thread.filename,
&thread.oldID, &thread.oldBoardID, &thread.oldParentID, &thread.Name, &thread.Tripcode, &thread.IsSecureTripcode,
&thread.Email, &thread.Subject, &thread.Message, &thread.MessageRaw, &thread.Password, &thread.filename,
&thread.filenameOriginal, &thread.fileChecksum, &thread.filesize, &thread.imageW, &thread.imageH,
&thread.thumbW, &thread.thumbH, &thread.IP, &thread.CreatedOn, &thread.autosage,
&thread.bumped, &thread.stickied, &thread.locked,
@ -137,8 +137,8 @@ func (m *Pre2021Migrator) MigratePosts() error {
for replyRows.Next() {
var reply migrationPost
if err = replyRows.Scan(
&reply.oldID, &reply.oldBoardID, &reply.oldParentID, &reply.Name, &reply.Tripcode, &reply.Email,
&reply.Subject, &reply.Message, &reply.MessageRaw, &reply.Password, &reply.filename,
&reply.oldID, &reply.oldBoardID, &reply.oldParentID, &reply.Name, &reply.Tripcode, &reply.IsSecureTripcode,
&reply.Email, &reply.Subject, &reply.Message, &reply.MessageRaw, &reply.Password, &reply.filename,
&reply.filenameOriginal, &reply.fileChecksum, &reply.filesize, &reply.imageW, &reply.imageH,
&reply.thumbW, &reply.thumbH, &reply.IP, &reply.CreatedOn, &reply.autosage,
&reply.bumped, &reply.stickied, &reply.locked,

View file

@ -8,7 +8,7 @@ default_style, locked, created_on, anonymous, forced_anon, autosage_after, no_im
redirect_to_thread, require_file, enable_catalog
FROM DBPREFIXboards`
postsQuery = `SELECT id, boardid, parentid, name, tripcode, email, subject, message, message_raw, password, filename,
postsQuery = `SELECT id, boardid, parentid, name, tripcode, is_secure_tripcode, email, subject, message, message_raw, password, filename,
filename_original, file_checksum, filesize, image_w, image_h, thumb_w, thumb_h, ip, timestamp, autosage,
bumped, stickied, locked FROM DBPREFIXposts WHERE deleted_timestamp IS NULL`