Project moved to https://github.com/c410-f3r/wtx
c410-f3r / oapth Goto Github PK
View Code? Open in Web Editor NEWFlexible version control for databases through SQL migrations
License: Apache License 2.0
Flexible version control for databases through SQL migrations
License: Apache License 2.0
Project moved to https://github.com/c410-f3r/wtx
See #5
See #5
See #5
See #5
See #5
See #5
See #5
See #5
See #5
See #5
Hi there!
I was just wondering if the project is still alive and what is missing to do a release on crates.
I am looking to switch my current diesel migrations to something more universal and your library seems very well made.
Thanks
This issue gathers all remaining missing aspects of clean
and also serves as a general tutorial.
The clean
method tries to clean all objects of a database, including user created schemas, but is very tricky to implement for all databases. To make life easier, the current implementation of flyway
is going to be used as a development reference (hope the flyway guys don't mind).
For example, let's pick PostgreSQL to see what flyway
does and what oapth
currently can do:
oapth/oapth/src/fixed_sql_commands/pg.rs
Line 20 in ff8c02d
By looking into both projects, it is possible to see that oapth
doesn't remove sequences, so let's implement it.
Let's create the function that lists all sequences (don't forget to link and credit the original flyway
source):
// https://github.com/flyway/flyway/blob/master/flyway-core/src/main/java/org/flywaydb/core/internal/database/postgresql/PostgreSQLSchema.java
#[oapth_macros::dev_tools_]
#[inline]
pub async fn sequences<B>(back_end: &mut B, schema: &str) -> crate::Result<Vec<String>>
where
B: crate::BackEnd
{
let mut buffer = ArrayString::<[u8; 128]>::new();
buffer.write_fmt(format_args!(
"SELECT sequence_name AS generic_column FROM information_schema.sequences WHERE sequence_schema = '{schema}'",
schema = schema
))?;
Ok(back_end.query_string(&buffer).await?)
}
And insert the drop statement within the clean
function:
for sequence in sequences(back_end, "public").await? {
buffer.write_fmt(format_args!("DROP SEQUENCE {};", domain))?;
}
Since this is a specific behavior of PostgreSQL
, we are going to include some code into the already existing clean_drops_all_objs
test:
...
c.back_end.execute("CREATE SEQUENCE serial START 101;").await.unwrap();
...
assert_eq!(crate::fixed_sql_commands::pg::sequences(&mut c.back_end).await.unwrap().len(), 1);
...
c.clean().await.unwrap();
...
assert_eq!(crate::fixed_sql_commands::pg::sequences(&mut c.back_end).await.unwrap().len(), 0);
...
Now it is only a matter of running the test. Go to the project root directory and type ./scripts/integration-tests-pg.sh
to run your shinny new test through the diesel
, tokio_postgres
and sqlx
database bridges.
Check out https://github.com/c410-f3r/oapth/blob/master/CONTRIBUTING.md for more information.
See #5
See #5
See #5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.