diff --git a/src/migration/migrations/2021-08-28T124959Z_RemoveFeatureFlags.go b/src/migration/migrations/2021-08-28T124959Z_RemoveFeatureFlags.go
new file mode 100644
index 00000000..13bc1592
--- /dev/null
+++ b/src/migration/migrations/2021-08-28T124959Z_RemoveFeatureFlags.go
@@ -0,0 +1,61 @@
+package migrations
+
+import (
+ "context"
+ "time"
+
+ "git.handmade.network/hmn/hmn/src/migration/types"
+ "git.handmade.network/hmn/hmn/src/oops"
+ "github.com/jackc/pgx/v4"
+)
+
+func init() {
+ registerMigration(RemoveFeatureFlags{})
+}
+
+type RemoveFeatureFlags struct{}
+
+func (m RemoveFeatureFlags) Version() types.MigrationVersion {
+ return types.MigrationVersion(time.Date(2021, 8, 28, 12, 49, 59, 0, time.UTC))
+}
+
+func (m RemoveFeatureFlags) Name() string {
+ return "RemoveFeatureFlags"
+}
+
+func (m RemoveFeatureFlags) Description() string {
+ return "Convert project feature flags to booleans"
+}
+
+func (m RemoveFeatureFlags) Up(ctx context.Context, tx pgx.Tx) error {
+ _, err := tx.Exec(ctx, `
+ ALTER TABLE handmade_project
+ DROP wiki_flags,
+ DROP wiki_last_updated,
+ DROP static_flags,
+ DROP annotation_flags
+ `)
+ if err != nil {
+ return oops.New(err, "failed to drop stupid old columns")
+ }
+
+ _, err = tx.Exec(ctx, `
+ ALTER TABLE handmade_project
+ ALTER forum_flags TYPE BOOLEAN USING forum_flags > 0,
+ ALTER blog_flags TYPE BOOLEAN USING blog_flags > 0,
+ ALTER library_flags TYPE BOOLEAN USING library_flags > 0;
+
+ ALTER TABLE handmade_project RENAME forum_flags TO forum_enabled;
+ ALTER TABLE handmade_project RENAME blog_flags TO blog_enabled;
+ ALTER TABLE handmade_project RENAME library_flags TO library_enabled;
+ `)
+ if err != nil {
+ return oops.New(err, "failed to convert flags to bools")
+ }
+
+ return nil
+}
+
+func (m RemoveFeatureFlags) Down(ctx context.Context, tx pgx.Tx) error {
+ panic("Implement me")
+}
diff --git a/src/models/project.go b/src/models/project.go
index 193b5f34..1cd90670 100644
--- a/src/models/project.go
+++ b/src/models/project.go
@@ -57,6 +57,10 @@ type Project struct {
Featured bool `db:"featured"`
DateApproved time.Time `db:"date_approved"`
AllLastUpdated time.Time `db:"all_last_updated"`
+
+ ForumEnabled bool `db:"forum_enabled"`
+ BlogEnabled bool `db:"blog_enabled"`
+ LibraryEnabled bool `db:"library_enabled"`
}
func (p *Project) IsHMN() bool {
diff --git a/src/templates/mapping.go b/src/templates/mapping.go
index de1633ce..36e4ee73 100644
--- a/src/templates/mapping.go
+++ b/src/templates/mapping.go
@@ -91,9 +91,9 @@ func ProjectToTemplate(p *models.Project, theme string) Project {
IsHMN: p.IsHMN(),
- HasBlog: true, // TODO: Check flag sets or whatever
- HasForum: true,
- HasLibrary: true,
+ HasBlog: p.BlogEnabled,
+ HasForum: p.ForumEnabled,
+ HasLibrary: false, // TODO: port the library lol
DateApproved: p.DateApproved,
}
diff --git a/src/templates/src/include/header.html b/src/templates/src/include/header.html
index fbeb5e23..a58e905e 100644
--- a/src/templates/src/include/header.html
+++ b/src/templates/src/include/header.html
@@ -57,7 +57,6 @@
{{ if .Project.IsHMN }}
Mission
{{ end }}
- {{/* {% if project.default_annotation_category %} */}}
{{ if .Header.EpisodeGuideUrl }}
Episode Guide
{{ end }}