diff --git a/database/base.go b/database/base.go index 60bd341..69944b1 100644 --- a/database/base.go +++ b/database/base.go @@ -28,14 +28,18 @@ func SetupDb() (func(), error) { db, err := sqlx.Connect(config.GlobalComputedConfig.DatabaseDriver, config.GlobalComputedConfig.DatabaseDSN) if err == nil { amdb = db - setupAdCache() - setupUserCache() - setupContactsCache() - setupCommunityCache() - setupServicesCache() - setupConferenceCache() - exitfns = append(exitfns, setupAuditWriter()) - exitfns = append(exitfns, setupIPBanSweep()) + g, err := AmGlobals(context.Background()) + if err == nil { + setupAdCache() + setupUserCache() + setupContactsCache() + setupCommunityCache() + setupServicesCache() + setupConferenceCache() + exitfns = append(exitfns, setupAuditWriter()) + exitfns = append(exitfns, setupIPBanSweep()) + log.Infof("SetupDb(): database version %s", g.Version) + } } return func() { slices.Reverse(exitfns) diff --git a/database/globals.go b/database/globals.go index c8544e1..961d19f 100644 --- a/database/globals.go +++ b/database/globals.go @@ -20,14 +20,15 @@ import ( // Globals contains the global data. type Globals struct { Mutex sync.Mutex - PostsPerPage int32 `db:"posts_per_page"` - OldPostsAtTop int32 `db:"old_posts_at_top"` - MaxSearchPage int32 `db:"max_search_page"` - MaxCommunityMemberPage int32 `db:"max_comm_mbr_page"` - MaxConferenceMemberPage int32 `db:"max_conf_mbr_page"` - FrontPagePosts int32 `db:"fp_posts"` - NumAuditPage int32 `db:"num_audit_page"` - CommunityCreateLevel int32 `db:"comm_create_lvl"` + Version string `db:"version"` + PostsPerPage int32 `db:"posts_per_page"` + OldPostsAtTop int32 `db:"old_posts_at_top"` + MaxSearchPage int32 `db:"max_search_page"` + MaxCommunityMemberPage int32 `db:"max_comm_mbr_page"` + MaxConferenceMemberPage int32 `db:"max_conf_mbr_page"` + FrontPagePosts int32 `db:"fp_posts"` + NumAuditPage int32 `db:"num_audit_page"` + CommunityCreateLevel int32 `db:"comm_create_lvl"` flags *util.OptionSet } @@ -63,6 +64,7 @@ var globalPropMutex sync.Mutex // Clone clones the entire global state. func (g *Globals) Clone() *Globals { rc := &Globals{ + Version: g.Version, PostsPerPage: g.PostsPerPage, OldPostsAtTop: g.OldPostsAtTop, MaxSearchPage: g.MaxSearchPage, @@ -126,6 +128,7 @@ func AmReplaceGlobals(ctx context.Context, ng *Globals) error { if err != nil { return err } + ng.Version = theGlobals.Version ng.flags = nil theGlobals = ng return nil diff --git a/setup/database-contents.sql b/setup/database-contents.sql index 4ed66e1..6962678 100644 --- a/setup/database-contents.sql +++ b/setup/database-contents.sql @@ -17,6 +17,7 @@ # likely to edit "on the fly." Stuff that can only be updated with a shutdown should go # in the XML config file. This table has ONLY ONE ROW! CREATE TABLE globals ( + version CHAR(10) NOT NULL, posts_per_page INT NOT NULL, old_posts_at_top INT NOT NULL, max_search_page INT NOT NULL, @@ -833,9 +834,9 @@ INSERT INTO adverts (imagepath) VALUES ############################################################################## # Initialize the system globals table. -INSERT INTO globals (posts_per_page, old_posts_at_top, max_search_page, max_comm_mbr_page, max_conf_mbr_page, +INSERT INTO globals (version, posts_per_page, old_posts_at_top, max_search_page, max_comm_mbr_page, max_conf_mbr_page, fp_posts, num_audit_page, comm_create_lvl) - VALUES (20, 2, 20, 50, 50, 10, 100, 1000); + VALUES ('2026030501', 20, 2, 20, 50, 50, 10, 100, 1000); # Initialize the global properies table. INSERT INTO propglobal (ndx, data) diff --git a/setup/database.sql b/setup/database.sql index de30439..f49c403 100644 --- a/setup/database.sql +++ b/setup/database.sql @@ -25,6 +25,7 @@ USE amsterdam; # likely to edit "on the fly." Stuff that can only be updated with a shutdown should go # in the XML config file. This table has ONLY ONE ROW! CREATE TABLE globals ( + version CHAR(10) NOT NULL, posts_per_page INT NOT NULL, old_posts_at_top INT NOT NULL, max_search_page INT NOT NULL, @@ -851,9 +852,9 @@ INSERT INTO adverts (imagepath) VALUES ############################################################################## # Initialize the system globals table. -INSERT INTO globals (posts_per_page, old_posts_at_top, max_search_page, max_comm_mbr_page, max_conf_mbr_page, +INSERT INTO globals (version, posts_per_page, old_posts_at_top, max_search_page, max_comm_mbr_page, max_conf_mbr_page, fp_posts, num_audit_page, comm_create_lvl) - VALUES (20, 2, 20, 50, 50, 10, 100, 1000); + VALUES ('2026030501', 20, 2, 20, 50, 50, 10, 100, 1000); # Initialize the global properies table. INSERT INTO propglobal (ndx, data) diff --git a/setup/migrate-venice.sql b/setup/migrate-venice.sql index b7441ca..2eb1c99 100644 --- a/setup/migrate-venice.sql +++ b/setup/migrate-venice.sql @@ -49,3 +49,7 @@ 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; diff --git a/top.go b/top.go index 2f5e355..1693b0c 100644 --- a/top.go +++ b/top.go @@ -240,6 +240,13 @@ func TopPage(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func AboutPage(ctxt ui.AmContext) (string, any) { + // Set the database version. + g, err := database.AmGlobals(ctxt.Ctx()) + if err != nil { + return "error", err + } + ctxt.VarMap().Set("dbVersion", g.Version) + // Set the page title. ctxt.SetFrameTitle("About Amsterdam") return "framed", "about.jet" diff --git a/ui/views/about.jet b/ui/views/about.jet index 04e9489..6ebb6fe 100644 --- a/ui/views/about.jet +++ b/ui/views/about.jet @@ -10,23 +10,19 @@
+
+
Copyright © {{ AmsterdamCopyright }} Erbosoft Metaverse Design Solutions, All Rights Reserved.
-+
This software is subject to the - Mozilla Public License Version 2.0. + Mozilla Public License Version 2.0. It is distributed on an "AS IS" basis, without warranty of any kind, either express or implied. See the License for the specific language governing rights and limitations under the License.
@@ -34,8 +30,8 @@+
Thanks to: Howard, who thought it up; Andre, who rescued it the first time; the Electric Minds community, who rescued it again; and Nicole, without whom none of this would have been possible.
@@ -53,11 +49,7 @@
-
+