mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-25 00:54:05 +01:00
applyMigration() already wraps each file in a db.Begin()/tx.Commit() transaction. The inner BEGIN/COMMIT in these files caused the outer transaction to commit early, leaving applyMigration trying to insert into schema_version on an idle connection: pq: unexpected transaction status idle Affected: 0012_guild_invites, 0014_return_guilds, 0015_tournament.
20 lines
882 B
SQL
20 lines
882 B
SQL
-- Dedicated table for guild-initiated scout invitations, separate from
|
|
-- player-initiated applications. This gives each invitation a real serial PK
|
|
-- so the client's InvitationID field can map to an actual database row
|
|
-- instead of being aliased to the character ID.
|
|
CREATE TABLE guild_invites (
|
|
id serial PRIMARY KEY,
|
|
guild_id integer REFERENCES guilds(id),
|
|
character_id integer REFERENCES characters(id),
|
|
actor_id integer REFERENCES characters(id),
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
-- Migrate any existing scout invitations from guild_applications.
|
|
INSERT INTO guild_invites (guild_id, character_id, actor_id, created_at)
|
|
SELECT guild_id, character_id, actor_id, COALESCE(created_at, now())
|
|
FROM guild_applications
|
|
WHERE application_type = 'invited';
|
|
|
|
DELETE FROM guild_applications WHERE application_type = 'invited';
|