|
1 | 1 | ---
|
2 | 2 | source: crates/crates_io_database_dump/src/lib.rs
|
3 | 3 | expression: content
|
| 4 | +snapshot_kind: text |
4 | 5 | ---
|
5 | 6 | BEGIN;
|
6 | 7 | -- Disable triggers on each table.
|
|
9 | 10 | ALTER TABLE "crate_downloads" DISABLE TRIGGER ALL;
|
10 | 11 | ALTER TABLE "crates" DISABLE TRIGGER ALL;
|
11 | 12 | ALTER TABLE "keywords" DISABLE TRIGGER ALL;
|
| 13 | + ALTER TABLE "linked_accounts" DISABLE TRIGGER ALL; |
12 | 14 | ALTER TABLE "metadata" DISABLE TRIGGER ALL;
|
13 | 15 | ALTER TABLE "reserved_crate_names" DISABLE TRIGGER ALL;
|
14 | 16 | ALTER TABLE "teams" DISABLE TRIGGER ALL;
|
|
23 | 25 |
|
24 | 26 | -- Set defaults for non-nullable columns not included in the dump.
|
25 | 27 |
|
| 28 | + ALTER TABLE "linked_accounts" ALTER COLUMN "access_token" SET DEFAULT ''; |
26 | 29 | ALTER TABLE "users" ALTER COLUMN "gh_access_token" SET DEFAULT '';
|
27 | 30 |
|
28 | 31 | -- Truncate all tables.
|
|
31 | 34 | TRUNCATE "crate_downloads" RESTART IDENTITY CASCADE;
|
32 | 35 | TRUNCATE "crates" RESTART IDENTITY CASCADE;
|
33 | 36 | TRUNCATE "keywords" RESTART IDENTITY CASCADE;
|
| 37 | + TRUNCATE "linked_accounts" RESTART IDENTITY CASCADE; |
34 | 38 | TRUNCATE "metadata" RESTART IDENTITY CASCADE;
|
35 | 39 | TRUNCATE "reserved_crate_names" RESTART IDENTITY CASCADE;
|
36 | 40 | TRUNCATE "teams" RESTART IDENTITY CASCADE;
|
|
52 | 56 | \copy "crate_downloads" ("crate_id", "downloads") FROM 'data/crate_downloads.csv' WITH CSV HEADER
|
53 | 57 | \copy "crates" ("created_at", "description", "documentation", "homepage", "id", "max_features", "max_upload_size", "name", "readme", "repository", "updated_at") FROM 'data/crates.csv' WITH CSV HEADER
|
54 | 58 | \copy "keywords" ("crates_cnt", "created_at", "id", "keyword") FROM 'data/keywords.csv' WITH CSV HEADER
|
| 59 | + \copy "linked_accounts" ("account_id", "avatar", "login", "provider", "user_id") FROM 'data/linked_accounts.csv' WITH CSV HEADER |
55 | 60 | \copy "metadata" ("total_downloads") FROM 'data/metadata.csv' WITH CSV HEADER
|
56 | 61 | \copy "reserved_crate_names" ("name") FROM 'data/reserved_crate_names.csv' WITH CSV HEADER
|
57 | 62 | \copy "teams" ("avatar", "github_id", "id", "login", "name", "org_id") FROM 'data/teams.csv' WITH CSV HEADER
|
|
66 | 71 |
|
67 | 72 | -- Drop the defaults again.
|
68 | 73 |
|
| 74 | + ALTER TABLE "linked_accounts" ALTER COLUMN "access_token" DROP DEFAULT; |
69 | 75 | ALTER TABLE "users" ALTER COLUMN "gh_access_token" DROP DEFAULT;
|
70 | 76 |
|
71 | 77 | -- Reenable triggers on each table.
|
|
74 | 80 | ALTER TABLE "crate_downloads" ENABLE TRIGGER ALL;
|
75 | 81 | ALTER TABLE "crates" ENABLE TRIGGER ALL;
|
76 | 82 | ALTER TABLE "keywords" ENABLE TRIGGER ALL;
|
| 83 | + ALTER TABLE "linked_accounts" ENABLE TRIGGER ALL; |
77 | 84 | ALTER TABLE "metadata" ENABLE TRIGGER ALL;
|
78 | 85 | ALTER TABLE "reserved_crate_names" ENABLE TRIGGER ALL;
|
79 | 86 | ALTER TABLE "teams" ENABLE TRIGGER ALL;
|
|
0 commit comments