Skip to content

Commit cd46105

Browse files
committed
sea-schema-sync
1 parent 1830d74 commit cd46105

133 files changed

Lines changed: 300776 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rust.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ jobs:
111111
~/.cargo/git
112112
Cargo.lock
113113
target
114+
sea-schema-sync/Cargo.lock
115+
sea-schema-sync/target
114116
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-sqlite-${{ matrix.project }}
115117
- run: cargo build --manifest-path tests/${{ matrix.project }}/Cargo.toml
118+
- run: cargo build --manifest-path sea-schema-sync/tests/${{ matrix.project }}/Cargo.toml
116119
- run: cargo test --manifest-path tests/${{ matrix.project }}/Cargo.toml --no-run
120+
- run: cargo test --manifest-path sea-schema-sync/tests/${{ matrix.project }}/Cargo.toml --no-run
117121

118122
mysql:
119123
name: MySQL
@@ -279,6 +283,10 @@ jobs:
279283
~/.cargo/git
280284
Cargo.lock
281285
target
286+
sea-schema-sync/Cargo.lock
287+
sea-schema-sync/target
282288
key: ${{ github.sha }}-${{ github.run_id }}-${{ runner.os }}-sqlite-${{ matrix.project }}
283289
- run: cargo run --manifest-path tests/${{ matrix.project }}/Cargo.toml
290+
- run: cargo run --manifest-path sea-schema-sync/tests/${{ matrix.project }}/Cargo.toml
284291
- run: cargo test --manifest-path tests/${{ matrix.project }}/Cargo.toml
292+
- run: cargo test --manifest-path sea-schema-sync/tests/${{ matrix.project }}/Cargo.toml

build-tools/make-sync.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
rm -rf sea-schema-sync/src
2+
rm -rf sea-schema-sync/tests
3+
cp -r src sea-schema-sync
4+
mkdir -p sea-schema-sync/tests/writer
5+
mkdir -p sea-schema-sync/tests/live
6+
mkdir -p sea-schema-sync/tests/discovery
7+
cp -r tests/writer/sqlite sea-schema-sync/tests/writer
8+
cp -r tests/live/sqlite sea-schema-sync/tests/live
9+
cp -r tests/discovery/sqlite sea-schema-sync/tests/discovery
10+
cp -r tests/sakila sea-schema-sync/tests
11+
rm -rf sea-schema-sync/src/bin
12+
cd sea-schema-sync
13+
find src -type f -name '*.rs' -exec sed -i '' 's/async //' {} +
14+
find tests -type f -name '*.rs' -exec sed -i '' 's/async //' {} +
15+
find src -type f -name '*.rs' -exec sed -i '' 's/\.await//' {} +
16+
find tests -type f -name '*.rs' -exec sed -i '' 's/\.await//' {} +
17+
find src -type f -name '*.rs' -exec sed -i '' 's/not(feature = "sqlx-sqlite")/all(not(feature = "rusqlite"), not(feature = "sqlx-sqlite"))/' {} +
18+
find src -type f -name '*.rs' -exec sed -i '' 's/#\[cfg(feature = "sqlx-sqlite")\]/#\[cfg(feature = "rusqlite")\]/' {} +
19+
find tests -type f -name 'Cargo.toml' -exec sed -i '' 's/sea-schema/sea-schema-sync/' {} +
20+
find tests -type f -name 'Cargo.toml' -exec sed -i '' 's/sqlx-sqlite/rusqlite/' {} +
21+
find tests -type f -name 'Cargo.toml' -exec sed -i '' 's/, "runtime-async-std-native-tls"//' {} +
22+
find tests -type f -name 'Cargo.toml' -exec sed -i '' '/sqlx/d' {} +
23+
find tests -type f -name 'Cargo.toml' -exec sed -i '' '/async-std/d' {} +
24+
find tests -type f -name '*.rs' -exec sed -i '' '/async_std/d' {} +
25+
find tests -type f -name 'Cargo.toml' -exec sed -i '' 's/, default-features = false//' {} +
26+
find src -type f -name '*.rs' -exec sed -i '' 's/sqlx_types::/rusqlite_types::/' {} +
27+
find tests -type f -name '*.rs' -exec sed -i '' 's/sqlx_types::/rusqlite_types::/' {} +
28+
find src -type f -name '*.rs' -exec sed -i '' "s/SqlxRow/RusqliteRow/g" {} +
29+
find src -type f -name '*.rs' -exec sed -i '' 's/SqlxError/RusqliteError/g' {} +
30+
find src -type f -name '*.rs' -exec sed -i '' 's/SQLx/Rusqlite/' {} +
31+
find src -type f -name '*.rs' -exec sed -i '' 's/SqlitePool/RusqliteConnection/' {} +
32+
find src -type f -name '*.rs' -exec sed -i '' '/#\[async_trait::async_trait\]/d' {} +
33+
find src -type f -name '*.rs' -exec sed -i '' 's/ \+ Sync//' {} +
34+
cargo fmt

sea-schema-sync/Cargo.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[workspace]
2+
members = [
3+
".",
4+
"tests/discovery/sqlite",
5+
"tests/live/sqlite",
6+
"tests/writer/sqlite",
7+
]
8+
9+
[package]
10+
name = "sea-schema-sync"
11+
version = "0.17.0-rc.15"
12+
authors = [ "Chris Tsang <tyt2y7@gmail.com>" ]
13+
edition = "2024"
14+
description = "🌿 SQL schema definition and discovery"
15+
license = "MIT OR Apache-2.0"
16+
documentation = "https://docs.rs/sea-schema"
17+
repository = "https://github.com/SeaQL/sea-schema"
18+
categories = ["database"]
19+
keywords = ["database", "sql", "mysql", "postgres"]
20+
rust-version = "1.85.0"
21+
22+
[package.metadata.docs.rs]
23+
features = ["default"]
24+
rustdoc-args = ["--cfg", "docsrs"]
25+
26+
[lib]
27+
name = "sea_schema"
28+
path = "src/lib.rs"
29+
30+
[dependencies]
31+
async-trait = { version = "0.1", default-features = false }
32+
sea-schema-derive = { version = "0.3.0", path = "../sea-schema-derive", default-features = false }
33+
sea-query = { version = "1.0.0-rc.18", default-features = false, features = ["derive"] }
34+
sea-query-rusqlite = { version = "0.8.0-rc.11", optional = true }
35+
serde = { version = "1", default-features = false, optional = true, features = ["derive"] }
36+
log = { version = "0.4", default-features = false, optional = true }
37+
38+
[features]
39+
default = ["sync", "sqlite", "discovery", "writer", "probe"]
40+
debug-print = ["log"]
41+
mysql = ["sea-query/backend-mysql"]
42+
postgres = ["sea-query/backend-postgres"]
43+
postgres-vector = ["sea-query/postgres-vector"]
44+
sqlite = ["sea-query/backend-sqlite"]
45+
def = []
46+
discovery = ["parser"]
47+
parser = ["query"]
48+
query = ["def"]
49+
writer = ["def"]
50+
planetscale = []
51+
sync = []
52+
probe = ["query"]
53+
sqlx-dep = []
54+
sqlx-mysql = []
55+
sqlx-postgres = []
56+
sqlx-sqlite = []
57+
rusqlite = ["sea-query-rusqlite"]
58+
with-serde = ["serde"]
59+
60+
# This allows us to develop using a local version of sea-query
61+
[patch.crates-io]
62+
# sea-query = { path = "../sea-query" }
63+
# sea-query = { git = "https://github.com/SeaQL/sea-query", branch = "master" }

sea-schema-sync/src/connection.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use crate::rusqlite_types::{RusqliteError, RusqliteRow};
2+
use sea_query::SelectStatement;
3+
4+
pub trait Connection: Sized {
5+
fn query_all(&self, select: SelectStatement) -> Result<Vec<RusqliteRow>, RusqliteError>;
6+
7+
fn query_all_raw(&self, sql: String) -> Result<Vec<RusqliteRow>, RusqliteError>;
8+
}

sea-schema-sync/src/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![cfg_attr(docsrs, feature(doc_cfg))]
2+
3+
#[cfg(feature = "mysql")]
4+
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
5+
pub mod mysql;
6+
7+
#[cfg(feature = "postgres")]
8+
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
9+
pub mod postgres;
10+
11+
#[cfg(feature = "sqlite")]
12+
#[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
13+
pub mod sqlite;
14+
15+
pub use sea_query;
16+
17+
pub(crate) mod parser;
18+
19+
#[cfg(not(feature = "sync"))]
20+
pub mod sqlx_types;
21+
22+
#[cfg(feature = "sync")]
23+
pub mod rusqlite_types;
24+
25+
pub(crate) mod util;
26+
27+
pub mod name;
28+
pub use name::*;
29+
30+
mod connection;
31+
pub use connection::*;
32+
33+
#[cfg(feature = "probe")]
34+
pub mod probe;

0 commit comments

Comments
 (0)