moved Venice migration script into embeds as well
This commit is contained in:
+23
-4
@@ -38,6 +38,9 @@ var errMySQLNoColumn = &mysql.MySQLError{Number: 1054}
|
||||
//go:embed mysql-install.sql
|
||||
var installScriptMySQL string
|
||||
|
||||
//go:embed mysql-convert.sql
|
||||
var convertScriptMySQL string
|
||||
|
||||
// amdb is the reference to the Amsterdam database.
|
||||
var amdb *sqlx.DB
|
||||
|
||||
@@ -82,6 +85,16 @@ func databaseInstallScript() (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// databaseConvertScript returns the script to convert a Venice database to Amsterdam.
|
||||
func databaseConvertScript() (string, error) {
|
||||
switch config.GlobalComputedConfig.DatabaseDriver {
|
||||
case "mysql":
|
||||
return convertScriptMySQL, nil
|
||||
default: // N.B.: Not to be implemented for any database type besides MySQL!
|
||||
return "", fmt.Errorf("No conversion script for database driver: %s", config.GlobalComputedConfig.DatabaseDriver)
|
||||
}
|
||||
}
|
||||
|
||||
// prepareDB prepares the database if it's not yet been loaded.
|
||||
func prepareDB() (string, error) {
|
||||
dsn := buildMysqlDSN(true)
|
||||
@@ -106,14 +119,20 @@ func prepareDB() (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failure of install script: %w", err)
|
||||
}
|
||||
version, err = databaseVersionNumber(db)
|
||||
case classNeedConvert:
|
||||
convertScript, err := databaseConvertScript()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
case classNeedConvert:
|
||||
// TODO
|
||||
_, err = db.Exec(convertScript)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failure of conversion script: %w", err)
|
||||
}
|
||||
}
|
||||
version, err = databaseVersionNumber(db)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = nil // if get here, we are OK to go
|
||||
}
|
||||
// TODO: apply migration scripts
|
||||
return version, err
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Amsterdam Web Communities System
|
||||
# Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
ALTER TABLE globals RENAME COLUMN max_sig_mbr_page TO max_comm_mbr_page;
|
||||
ALTER TABLE globals RENAME COLUMN sig_create_lvl TO comm_create_lvl;
|
||||
|
||||
ALTER TABLE audit RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE audit RENAME INDEX sig_view TO comm_view;
|
||||
|
||||
ALTER TABLE contacts RENAME COLUMN owner_sigid TO owner_commid;
|
||||
|
||||
ALTER TABLE sigs RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE sigs RENAME COLUMN signame TO commname;
|
||||
ALTER TABLE sigs RENAME AS communities;
|
||||
|
||||
ALTER TABLE sigftrs RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE sigftrs RENAME AS commftrs;
|
||||
|
||||
ALTER TABLE sigmember RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE sigmember RENAME AS commmember;
|
||||
|
||||
ALTER TABLE sigban RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE sigban RENAME AS commban;
|
||||
|
||||
ALTER TABLE sigtoconf RENAME COLUMN sigid TO commid;
|
||||
ALTER TABLE sigtoconf RENAME AS commtoconf;
|
||||
|
||||
ALTER TABLE confhotlist RENAME COLUMN sigid TO commid;
|
||||
|
||||
ALTER TABLE postpublish RENAME COLUMN sigid TO commid;
|
||||
|
||||
ALTER TABLE ipban DROP INDEX by_mask;
|
||||
ALTER TABLE ipban DROP COLUMN address;
|
||||
ALTER TABLE ipban DROP COLUMN mask;
|
||||
ALTER TABLE ipban ADD COLUMN mask_hi BIGINT UNSIGNED NOT NULL AFTER id;
|
||||
ALTER TABLE ipban ADD COLUMN mask_lo BIGINT UNSIGNED NOT NULL AFTER id;
|
||||
ALTER TABLE ipban ADD COLUMN address_hi BIGINT UNSIGNED NOT NULL AFTER id;
|
||||
ALTER TABLE ipban ADD COLUMN address_lo BIGINT UNSIGNED NOT NULL AFTER id;
|
||||
ALTER TABLE ipban ADD INDEX by_mask (mask_hi, mask_lo);
|
||||
|
||||
ALTER TABLE users MODIFY COLUMN email_confnum INT DEFAULT 0;
|
||||
|
||||
DROP TABLE refaudit;
|
||||
|
||||
ALTER TABLE globals ADD COLUMN version CHAR(10) FIRST;
|
||||
UPDATE globals SET version = '2026030501';
|
||||
ALTER TABLE globals MODIFY COLUMN version CHAR(10) NOT NULL;
|
||||
Reference in New Issue
Block a user