diff --git a/cmd/hanyuu/migrations.go b/cmd/hanyuu/migrations.go index 17e6ded1..7d35f092 100644 --- a/cmd/hanyuu/migrations.go +++ b/cmd/hanyuu/migrations.go @@ -103,6 +103,17 @@ func (m migrateCmd) up(ctx context.Context, cfg config.Config) error { return err } + done := make(chan struct{}) + defer close(done) + + go func() { + select { + case <-ctx.Done(): + m.migrate.GracefulStop <- true + case <-done: + } + }() + return m.migrate.Up() } diff --git a/migrations/mysql/0007_eplay_dj.up.sql b/migrations/mysql/0007_eplay_dj.up.sql index 2127f818..6281b95d 100644 --- a/migrations/mysql/0007_eplay_dj.up.sql +++ b/migrations/mysql/0007_eplay_dj.up.sql @@ -1,3 +1,3 @@ ALTER TABLE eplay ADD COLUMN IF NOT EXISTS (djs_id INT DEFAULT NULL); -UPDATE eplay SET djs_id = (SELECT dj FROM listenlog WHERE eplay.dt <= listenlog.time ORDER BY listenlog.time ASC LIMIT 1); \ No newline at end of file +UPDATE eplay SET djs_id = (SELECT dj FROM listenlog WHERE eplay.dt >= listenlog.time ORDER BY listenlog.time ASC LIMIT 1); \ No newline at end of file