From 999996961e6e8ebcde125ff0022df875d62817b3 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Thu, 10 Oct 2024 20:52:46 -0400
Subject: Fix invalid migration.

The original version of this migration happened to work correctly, by accident, for databases with exactly one login. I missed this, and so did Kit, because both of our test databases _actually do_ contain exactly one login, and because I didn't run the tests before committing the migration.

The fixed version works correctly for all scenarios I tested (zero, one, and two users, not super thorough). I've added code to patch out the original migration hash in databases that have it; no further corrective work is needed, as if the migration failed, then it got backed out anyways, and if it succeeded, you fell into the "one user" case.
---
 migrations/20241009031441_login_created_at.sql | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'migrations/20241009031441_login_created_at.sql')

diff --git a/migrations/20241009031441_login_created_at.sql b/migrations/20241009031441_login_created_at.sql
index 001c48e..bef4c28 100644
--- a/migrations/20241009031441_login_created_at.sql
+++ b/migrations/20241009031441_login_created_at.sql
@@ -41,7 +41,8 @@ select
 	login.id
 from login
 left join message
-	on login.id = message.sender;
+	on login.id = message.sender
+group by login.id;
 
 insert into unsequenced (at, channel)
 select created_at, id
-- 
cgit v1.2.3

