g1t/services/repos/migrations/0002_rfc3339_timestamps.sql
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| RFC 3339 timestamps in identity and repos | 1 | -- created_at becomes RFC 3339 UTC text instead of Unix seconds. |
| 2 | PRAGMA defer_foreign_keys = on; | |
| 3 | ||
| 4 | -- Stored in Artifacts as "<namespace>--<name>". | |
| 5 | CREATE TABLE repos_new ( | |
| 6 | id TEXT PRIMARY KEY, | |
| 7 | namespace TEXT NOT NULL, | |
| 8 | name TEXT NOT NULL, | |
| 9 | description TEXT, | |
| 10 | is_private INTEGER NOT NULL DEFAULT 0, | |
| 11 | owner_id TEXT NOT NULL, | |
| 12 | default_branch TEXT NOT NULL DEFAULT 'main', | |
| 13 | -- Set on an attempt's working copy; those are hidden from listings. | |
| 14 | -- Refers to this table; the rename below carries the reference along. | |
| 15 | fork_of TEXT REFERENCES repos_new (id), | |
| 16 | created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), | |
| 17 | UNIQUE (namespace, name) | |
| 18 | ); | |
| 19 | INSERT INTO repos_new | |
| 20 | (id, namespace, name, description, is_private, owner_id, default_branch, fork_of, created_at) | |
| 21 | SELECT id, namespace, name, description, is_private, owner_id, default_branch, fork_of, | |
| 22 | strftime('%Y-%m-%dT%H:%M:%fZ', created_at, 'unixepoch') | |
| 23 | FROM repos; | |
| 24 | ||
| 25 | DROP TABLE repos; | |
| 26 | ALTER TABLE repos_new RENAME TO repos; | |
| 27 | CREATE INDEX repos_owner ON repos (owner_id); |