irongit

Git hosting and a container registry in one Rust binary (axum + Astro)

irongit/backend/migrations/0002_imports.sql
56 lines2.9 KBSQL
1-- Imports from GitHub. One row per run, one item per repository. The GitHub
2-- token is never stored: it lives in the running job's memory only, so an
3-- import interrupted by a restart is marked failed and can be started again.
4
5create table imports (
6 id bigserial primary key,
7 user_id bigint not null references users (account_id) on delete cascade,
8 owner_id bigint not null references accounts (id) on delete cascade,
9 source text not null default 'github' check (source in ('github')),
10 source_owner text not null,
11 status text not null default 'pending'
12 check (status in ('pending', 'running', 'done', 'failed', 'cancelled')),
13 visibility_mode text not null default 'keep' check (visibility_mode in ('keep', 'private', 'public')),
14 import_profile boolean not null default false,
15 link_emails boolean not null default false,
16 total integer not null default 0,
17 done integer not null default 0,
18 failed integer not null default 0,
19 notes text not null default '',
20 error text,
21 created_at timestamptz not null default now(),
22 started_at timestamptz,
23 finished_at timestamptz
24);
25create index imports_user on imports (user_id, created_at desc);
26
27create table import_items (
28 id bigserial primary key,
29 import_id bigint not null references imports (id) on delete cascade,
30 position integer not null,
31 source_name text not null,
32 target_name text not null,
33 visibility text not null check (visibility in ('public', 'private')),
34 description text not null default '',
35 default_branch text,
36 archived boolean not null default false,
37 clone_url text not null,
38 size_kb bigint not null default 0,
39 status text not null default 'pending'
40 check (status in ('pending', 'running', 'done', 'failed', 'skipped')),
41 repo_id bigint references repos (id) on delete set null,
42 commits integer not null default 0,
43 lfs_objects integer not null default 0,
44 error text,
45 started_at timestamptz,
46 finished_at timestamptz
47);
48create index import_items_import on import_items (import_id, position);
49
50-- Imported repositories show up in activity feeds as one "imported" event.
51alter table push_events drop constraint push_events_via_check;
52alter table push_events add constraint push_events_via_check check (via in ('http', 'ssh', 'web', 'import'));
53
54-- GitHub joins Google as a sign-in provider.
55alter table oauth_identities drop constraint oauth_identities_provider_check;
56alter table oauth_identities add constraint oauth_identities_provider_check check (provider in ('google', 'github'));