Skip to content

Commit ce16710

Browse files
committed
replace schemamama with sqlx migrations
1 parent 5522add commit ce16710

File tree

12 files changed

+711
-992
lines changed

12 files changed

+711
-992
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ jobs:
6060
--check \
6161
-- --all-targets --all-features
6262
63+
- name: test reverse migrations
64+
run: |
65+
# --target 0 means "revert everything"
66+
cargo sqlx migrate revert \
67+
--database-url $DOCSRS_DATABASE_URL \
68+
--target-version 0
69+
6370
- name: Clean up the database
6471
run: docker-compose down --volumes
6572

.sqlx/query-ce93aecd02be2e662c7a384174afc309d10ce84e09a46fcae768d324efa5c822.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 1 addition & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ thiserror = "1.0.26"
5050
comrak = { version = "0.19.0", default-features = false }
5151
syntect = { version = "5.0.0", default-features = false, features = ["parsing", "html", "dump-load", "regex-onig"] }
5252
toml = "0.8.0"
53-
schemamama = "0.3"
54-
schemamama_postgres = "0.3"
5553
prometheus = { version = "0.13.0", default-features = false }
5654
rustwide = { version = "0.16.0", features = ["unstable-toolchain-ci", "unstable"] }
5755
mime_guess = "2"
@@ -72,6 +70,7 @@ getrandom = "0.2.1"
7270
itertools = { version = "0.12.0", optional = true}
7371
rusqlite = { version = "0.29.0", features = ["bundled"] }
7472
moka = { version ="0.12.0", default-features = false, features = ["sync"]}
73+
hex = "0.4.3"
7574

7675
# Async
7776
tokio = { version = "1.0", features = ["rt-multi-thread", "signal", "macros"] }

build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ fn main() -> Result<()> {
7979
compile_sass(out_dir)?;
8080
write_known_targets(out_dir)?;
8181
compile_syntax(out_dir).context("could not compile syntax files")?;
82+
83+
// trigger recompilation when a new migration is added
84+
println!("cargo:rerun-if-changed=migrations");
8285
Ok(())
8386
}
8487

dockerfiles/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ COPY templates/style templates/style
5252
COPY vendor vendor/
5353
COPY assets assets/
5454
COPY .sqlx .sqlx/
55+
COPY migrations migrations/
5556

5657
RUN cargo build --release
5758

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
DROP TABLE blacklisted_crates CASCADE;
2+
DROP TABLE builds CASCADE;
3+
DROP TABLE cdn_invalidation_queue CASCADE;
4+
DROP TABLE compression_rels CASCADE;
5+
DROP TABLE config CASCADE;
6+
DROP TABLE crate_priorities CASCADE;
7+
DROP TABLE crates CASCADE;
8+
DROP TABLE database_versions CASCADE;
9+
DROP TABLE doc_coverage CASCADE;
10+
DROP TABLE files CASCADE;
11+
DROP TABLE keyword_rels CASCADE;
12+
DROP TABLE keywords CASCADE;
13+
DROP TABLE owner_rels CASCADE;
14+
DROP TABLE owners CASCADE;
15+
DROP TABLE queue CASCADE;
16+
DROP TABLE releases CASCADE;
17+
DROP TABLE repositories CASCADE;
18+
DROP TABLE sandbox_overrides CASCADE;
19+
DROP TYPE feature;
20+
DROP FUNCTION normalize_crate_name;

0 commit comments

Comments
 (0)