| 1 | -- Importing a repository from somewhere else. |
| 2 | -- |
| 3 | -- `import_state` is null for every repository that was created rather than imported, |
| 4 | -- and for every import that finished. That is the whole point of it being nullable: |
| 5 | -- the ordinary repository — which is nearly all of them — keeps the behaviour it had, |
| 6 | -- and only a row that says otherwise is treated as unready. A `ready` value would mean |
| 7 | -- every read had to remember that `ready` and null mean the same thing. |
| 8 | -- |
| 9 | -- `import_source` outlives the state deliberately. Where a repository came from stays |
| 10 | -- true after the copy finishes, and it is what a retry after a failure needs. |
| 11 | -- |
| 12 | -- `import_error` is only ever set alongside `import_state = 'failed'`. Not constrained |
| 13 | -- to that in SQL: the pairing is `Repository::fail_import`'s job, and a check |
| 14 | -- constraint here would be a second place the rule lived. |
| 15 | -- |
| 16 | -- No index. The only query that filters on this is the boot sweep, which runs once per |
| 17 | -- process against a table with tens of rows. |
| 18 | repositories add column import_state text; |
| 19 | repositories add column import_source text; |
| 20 | repositories add column import_error text; |