atproto pds in zig pds.zat.dev
pds atproto
24

Configure Feed

Select the types of activity you want to include in your feed.

Clean up sync event migrations

authored by

zzstoatzz and committed by
Tangled
(Jun 18, 2026, 6:45 PM +0300) 49c1981a 60809996

+14 -28
+14 -28
src/storage/store.zig
··· 3655 3655 } 3656 3656 3657 3657 fn migratePermissionedDataTables() !void { 3658 + try ensureMigrationTable(); 3659 + try migratePermissionedSpacesOwnerFk(); 3660 + try migratePermissionedSpaceActorState(); 3661 + try migratePermissionedRecordOplogRepo(); 3662 + try migratePermissionedDropMemberLists(); 3663 + } 3664 + 3665 + fn ensureMigrationTable() !void { 3658 3666 try conn.execNoArgs( 3659 3667 \\CREATE TABLE IF NOT EXISTS zds_migrations ( 3660 3668 \\ name TEXT PRIMARY KEY, 3661 3669 \\ applied_at INTEGER NOT NULL DEFAULT (unixepoch()) 3662 3670 \\) 3663 3671 ); 3664 - try migratePermissionedSpacesOwnerFk(); 3665 - try migratePermissionedSpaceActorState(); 3666 - try migratePermissionedRecordOplogRepo(); 3667 - try migratePermissionedDropMemberLists(); 3668 3672 } 3669 3673 3670 3674 fn migrationApplied(name: []const u8) !bool { ··· 3772 3776 } 3773 3777 3774 3778 fn migrateSeqEventsSync11() !void { 3775 - try conn.execNoArgs( 3776 - \\CREATE TABLE IF NOT EXISTS zds_migrations ( 3777 - \\ name TEXT PRIMARY KEY, 3778 - \\ applied_at INTEGER NOT NULL DEFAULT (unixepoch()) 3779 - \\) 3780 - ); 3781 - const row = try conn.row("SELECT 1 FROM zds_migrations WHERE name = 'sync11-seq-events'", .{}); 3782 - if (row != null) { 3783 - defer row.?.deinit(); 3784 - return; 3785 - } 3779 + const name = "sync11-seq-events"; 3780 + if (try migrationApplied(name)) return; 3786 3781 3787 3782 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 3788 3783 defer arena.deinit(); ··· 3793 3788 try conn.exclusiveTransaction(); 3794 3789 errdefer conn.rollback(); 3795 3790 try rebuildSeqEventsSync11Locked(allocator); 3796 - try conn.exec("INSERT INTO zds_migrations (name) VALUES (?)", .{"sync11-seq-events"}); 3791 + try markMigrationApplied(name); 3797 3792 try conn.commit(); 3798 3793 } 3799 3794 3800 3795 fn migrateSeqEventsSinceRev() !void { 3801 - try conn.execNoArgs( 3802 - \\CREATE TABLE IF NOT EXISTS zds_migrations ( 3803 - \\ name TEXT PRIMARY KEY, 3804 - \\ applied_at INTEGER NOT NULL DEFAULT (unixepoch()) 3805 - \\) 3806 - ); 3807 - const row = try conn.row("SELECT 1 FROM zds_migrations WHERE name = 'sync-since-rev-events'", .{}); 3808 - if (row != null) { 3809 - defer row.?.deinit(); 3810 - return; 3811 - } 3796 + const name = "sync-since-rev-events"; 3797 + if (try migrationApplied(name)) return; 3812 3798 3813 3799 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 3814 3800 defer arena.deinit(); ··· 3819 3805 try conn.exclusiveTransaction(); 3820 3806 errdefer conn.rollback(); 3821 3807 try rebuildSeqEventsSync11Locked(allocator); 3822 - try conn.exec("INSERT INTO zds_migrations (name) VALUES (?)", .{"sync-since-rev-events"}); 3808 + try markMigrationApplied(name); 3823 3809 try conn.commit(); 3824 3810 } 3825 3811