Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#![cfg(unix)]
use sqlx::migrate::Migrator;
use std::path::Path;
static EMBEDDED_SIMPLE: Migrator = sqlx::migrate!("tests/migrate/migrations_simple");
static EMBEDDED_REVERSIBLE: Migrator = sqlx::migrate!("tests/migrate/migrations_reversible");
static EMBEDDED_SYMLINK: Migrator = sqlx::migrate!("tests/migrate/migrations_symlink");
#[sqlx_macros::test]
async fn same_output() -> anyhow::Result<()> {
let runtime_simple = Migrator::new(Path::new("tests/migrate/migrations_simple")).await?;
let runtime_reversible =
Migrator::new(Path::new("tests/migrate/migrations_reversible")).await?;
let runtime_symlink = Migrator::new(Path::new("tests/migrate/migrations_symlink")).await?;
assert_same(&EMBEDDED_SIMPLE, &runtime_simple);
assert_same(&EMBEDDED_REVERSIBLE, &runtime_reversible);
assert_same(&EMBEDDED_SYMLINK, &runtime_symlink);
Ok(())
}
fn assert_same(embedded: &Migrator, runtime: &Migrator) {
assert_eq!(runtime.migrations.len(), embedded.migrations.len());
for (e, r) in embedded.iter().zip(runtime.iter()) {
assert_eq!(e.version, r.version);
assert_eq!(e.description, r.description);
assert_eq!(e.migration_type, r.migration_type);
assert_eq!(e.sql, r.sql);
assert_eq!(e.checksum, r.checksum);
}
}
@@ -0,0 +1 @@
DROP TABLE migrations_reversible_test;
@@ -0,0 +1,7 @@
CREATE TABLE migrations_reversible_test (
some_id BIGINT NOT NULL PRIMARY KEY,
some_payload BIGINT NOT NUll
);
INSERT INTO migrations_reversible_test (some_id, some_payload)
VALUES (1, 100);
@@ -0,0 +1,2 @@
UPDATE migrations_reversible_test
SET some_payload = some_payload - 1;
@@ -0,0 +1,2 @@
UPDATE migrations_reversible_test
SET some_payload = some_payload + 1;
@@ -0,0 +1,7 @@
CREATE TABLE migrations_simple_test (
some_id BIGINT NOT NULL PRIMARY KEY,
some_payload BIGINT NOT NUll
);
INSERT INTO migrations_simple_test (some_id, some_payload)
VALUES (1, 100);
@@ -0,0 +1,34 @@
-- Perform a tricky conversion of the payload.
--
-- This script will only succeed once and will fail if executed twice.
-- set up temporary target column
ALTER TABLE migrations_simple_test
ADD some_payload_tmp TEXT;
-- perform conversion
-- This will fail if `some_payload` is already a string column due to the addition.
-- We add a suffix after the addition to ensure that the SQL database does not silently cast the string back to an
-- integer.
UPDATE migrations_simple_test
SET some_payload_tmp = CONCAT(CAST((some_payload + 10) AS TEXT), '_suffix');
-- remove original column including the content
ALTER TABLE migrations_simple_test
DROP COLUMN some_payload;
-- prepare new payload column (nullable, so we can copy over the data)
ALTER TABLE migrations_simple_test
ADD some_payload TEXT;
-- copy new values
UPDATE migrations_simple_test
SET some_payload = some_payload_tmp;
-- "freeze" column
ALTER TABLE migrations_simple_test
ALTER COLUMN some_payload SET NOT NULL;
-- clean up
ALTER TABLE migrations_simple_test
DROP COLUMN some_payload_tmp;
+1
View File
@@ -0,0 +1 @@
migrations_simple