diff options
| author | 2024-01-05 13:39:31 +0100 | |
|---|---|---|
| committer | 2024-01-05 13:39:31 +0100 | |
| commit | d5e3996a18ee37fc4bdf5718632d3d19ac7a8c1b (patch) | |
| tree | 7b8df224893611c77cadc847c2fd8d7ec239b636 /internal/db/bundb | |
| parent | [bugfix] fix check for closed poll to account for non-zero closed time but in... (diff) | |
| download | gotosocial-d5e3996a18ee37fc4bdf5718632d3d19ac7a8c1b.tar.xz | |
[feature] Parse instance descriptors as markdown, show T&C on /about (#2481)
* [feature] Parse instance descriptors as markdown, show T&C on /about
* lint
* remove unnecessary nullzero tags
Diffstat (limited to 'internal/db/bundb')
| -rw-r--r-- | internal/db/bundb/migrations/20231227110845_instance_description_updates.go | 64 | 
1 files changed, 64 insertions, 0 deletions
| diff --git a/internal/db/bundb/migrations/20231227110845_instance_description_updates.go b/internal/db/bundb/migrations/20231227110845_instance_description_updates.go new file mode 100644 index 000000000..94914ff55 --- /dev/null +++ b/internal/db/bundb/migrations/20231227110845_instance_description_updates.go @@ -0,0 +1,64 @@ +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program.  If not, see <http://www.gnu.org/licenses/>. + +package migrations + +import ( +	"context" +	"strings" + +	"github.com/uptrace/bun" +) + +func init() { +	up := func(ctx context.Context, db *bun.DB) error { +		return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { +			columns := []string{ +				"short_description_text", +				"description_text", +				"terms_text", +			} + +			for _, column := range columns { +				_, err := tx.ExecContext(ctx, +					"ALTER TABLE ? ADD COLUMN ? TEXT", +					bun.Ident("instances"), bun.Ident(column), +				) +				if err != nil { +					e := err.Error() +					if !(strings.Contains(e, "already exists") || +						strings.Contains(e, "duplicate column name") || +						strings.Contains(e, "SQLSTATE 42701")) { +						return err +					} +				} +			} + +			return nil +		}) +	} + +	down := func(ctx context.Context, db *bun.DB) error { +		return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { +			return nil +		}) +	} + +	if err := Migrations.Register(up, down); err != nil { +		panic(err) +	} +} | 
