how to create SQL Lite Schema - sqlite

I'm retrospectively unit testing a zend application and want to use an SQL Lite database for convenience. In production we use MySQL updated with DB migrations. Simple question: How do I create an SQL Lite schema? Is it possible to automatically recreate the schema inside phpunit?
Many thanks for your help.

Are you using doctrine?
If so, you can generate the schema with doctrine's orm:schema-tool:create feature.
You can use this command to either dump the SQL, or generate your tables directly through the connection.

Related

Flyway init new db

I have existing database postgres which not using Flyway and i need replicate it.
How to move existing database state to new empty database?
I don't have any migration sql.
So I am expecting command like generateChangelog in Liquibase but it seems in Flyway not existing command like that.
Flyway currently only manages the scripts that you create. It doesn't create scripts for you. So, in order to take an existing database and get it into Flyway processing, you'll need to generate the scripts for that database. You can use the methods outlined here to get the scripts for your database. Then, just rename them to the Flyway standard. You'll be off and running.

In memory which supports Oracle "schema.package.function(IN, OUT)"

I have to write JUnit test cases for REST API created using Spring boot and Oracle. There is no dedicated test DB environment. So I planned to use the in-memory database. I did a POC on H2 database. Even after spending 3 days, I was able to do basic things but it is not fully compatible with Oracle. It didn't support In, Out parameter, also it didn't support "call schema.package.function(In, Out)". I was able to create schema and function but I was not able to create a package. Could you please suggest an in-memory which support the following
Should support schema, package and function creation.
Should support In, Out parameter
Should be lightweight
Should be compatible with Oracle and Java
HSQLDB supports IN and OUT parameters for PROCEDURES. You can mimic the schema.package.function(in, out) by renaming the database CATALOG as the name of the schema and creating a separate schema named as the package, then creating the function in that schema.
Alternatively, HyperXtremeSQL (http://hyperxtreme.co.uk) supports creation of package, procedure and function with Oracle syntax.

Store Flyway metadata table externally

So just exploring the possibility of using flyway to maintain my DDL statements against Amazon Athena using Athena provided JDBC driver, Athena supports only CREATE statements (hive DDL) and no INSERTS.
So if database metadata table is the only one that flyway creates and updates, Is there anyway I can externalize the creating, storing into a totally different database ?
Currently this is not possible in flyway, as the schema history is read from/written to the database defined by the current jdbc connection. You can see this for yourself in the JDBCTableSchemaHistory file.
If you wish to add this support, you could create a pull request on the repo, or just add an issue detailing exactly what you want the behaviour to be.

EF code first migration - Change Sql Azure table key

Sql Azure does not support changing a table key. There is a work around: create a new table, transfer the data, delete the old table.
Because of this limitation, EF (4.3) is not able to migrate my model after changing a table's key.
What can I do to get EF code first to accept the new database after applying the manual work around? (Without having to drop the entire database or touch other tables)
Thanks
With a bit of manual editing you can get everything of this done inside a code based migration.
Change the key in your model (through annotations or the fluent API).
Run add-migration from the package manager console to get a new code based migration.
Exchange the generated migration steps in the migration file with the create-transfer-delete-rename method required by Azure.
Now when you run the application, the update to change keys will be done using your custom migration steps fit for Azure, rather than the default code.

How to map a SQLite database to another?

I need to export the data of a SQLite database and import this data to another SQLite database. But the two databases have different schemas.
Does exist an open source tool that can help me doing that job?
The only opensource tool that i know is opendbcopy that i'm using for migrate from a database server to another and also for a similar kind of job that you want to do with SQLite but i've done it with PostgreSQL.
However opendbcopy is JDBC compliant and can connect to every database that have a JDBC driver, so you can try, also if the schema is not the same you can use the column mapping feature :
In addition i know also a good commercial alternative (that is easier to use) that is ESF Database Migration Toolkit .

Resources