Flyway: execute a single oracle sql file - flyway

In postgres, I can execute a single .sql file using sqlMigrationSuffixes.
But, I can't use the same option for oracle. The only way to do it in oracle is to create a different folder and put that single file in that folder. Not exactly my preference.
Is there another option for oracle that allows execution of a single .sql file ?
Additional Details:
OS: CENTOS 7
flyway.conf
flyway.url=${flyway:url}
flyway.user=${flyway:user}
flyway.password=${flyway:password}
flyway.schemas=${flyway:schemas}
flyway.locations=${flyway:locations}
flyway.sqlMigrationSuffixes=${flyway:sqlMigrationSuffixes}
Running from command line
flyway \
-url=... \
-user=... \
-password=... \
-schemas=... \
-locations=filesystem:oracle_sql \
-sqlMigrationSuffixes="Create_ro.sql" \
-placeholders.tableName=... \
-placeholders.roleName=... \
migrate
File structure
flyway
|-conf
|-flyway.conf
|-oracle_sql
|-R__create_ro.sql
|-R__create_rw.sql
|-R__create_user.sql
|-pg_sql
|-R__create_ro.sql
|-R__create_rw.sql
|-R__create_user.sql
The above only works for postgres. In order to be able to execute a single .sql file in oracle, I had to get rid of the sqlMigrationSuffixes and schemas, create a new config for oracle because of this then put each oracle .sql file in its own directory.
Below works. Not my preference, but works.
flyway.conf
flyway.url=${flyway:url}
flyway.user=${flyway:user}
flyway.password=${flyway:password}
flyway.locations=${flyway:locations}
File Structure
flyway
|-conf
|-oracle.conf
|-postgres.conf
|-oracle_sql
|-create_ro
|-R__create_ro.sql
|-create_rw
|-R__create_rw.sql
|-create_user
|-R__create_user.sql
|-pg_sql
|-R__create_ro.sql
|-R__create_rw.sql
|-R__create_user.sql

Related

run zsh command for all files in a folder

I have a models folder that contains multiple sql files for example models/mart/table1.sql, models/mart/table2.sql, models/mart/table3.sql
I run this command manually on the terminal:
dbt run-operation generate_model_yaml --args '{"model_name": "table1"}'
However, instead of running it individually for each table, I want to include it in the Bitbucket pipeline. How can I modify the command such that it runs in a loop? It should be able to extract the tablename (filename) for all files from a specified folder eg (models/mart) and then run the command accordingly by replacing the model_name by the filename each time?
pipelines:
custom:
dbt-run-default:
- step:
name: 'Compile'
image: fishtownanalytics/dbt:1.0.0
script:
- cd dbt_4flow
- dbt deps --profiles-dir ./profiles
I'm not sure I quite understand which parts of the paths you want to pick apart. Does this work?
for file in models/mart/*.sql; do
table=$(basename "$file" .sql)
model=${file%/*}
printf " --args '{\"%s\": \"%s\"}'\n" "$model" "$table"
dbt run-operation generate_model_yaml --args "{\"model_name\": \"$table\"}"
done

How should I specify path syntactically for sqlite3 in my .bashrc file?

The SQLite folder containing sqlite3.exe is in C:\.
I am trying to add a path to my .bashrc that will allow me to use the sqlite3 command shell from C:\Users\User.
Again, structure is:
C:\Users\User (using Git bash here) and
C:\sqlite\
sqlite3.exe
sqldiff.exe
sqlite3.def
sqlite3.dll
sqlite3_analyzer.exe
I am attempting to use the sqlite3 command shell in Git bash on windows 8.1.
This is what is in my .bashrc file per Janos recommendation:
alias 'subl="C://Program Files/Sublime Text 3/sublime_text.exe"'
PATH=/c/sqlite/:$PATH
Is there possibly anything else missing?

How to install flyway DB migration tool in CentOS?

I am trying to install flyway on a centOS machine.
I have downloaded Flyway command line tar file and extracted it.
I tried to execute some flyway commands but dnt work
it says "-bash: flyway: command not found"
Did I miss anything.
Do I have to install?
I dnt find any tutorials for Installation.
No need to install it, it's simply a shell script with a JRE, the Flyway Java libraries and associated resources.
Sounds like you need to add the location of to the flyway shell script to your PATH variable if you want to run it without being in the directory or specifying the path.
e.g.
If you have extracted flyway-commandline-4.1.2-linux-x64.tar.gz to /opt/flyway/flyway-4.1.2 which looks like:
flyway-4.1.2
├── conf
├── flyway # <---- The shell script
├── lib
└── ...
somewhere in your setup you want that on your PATH
export PATH=$PATH:/opt/flyway/flyway-4.1.2
Note the command line documentation mentions the first two steps as
download the tool and extract it
cd into the extracted directory.

Need help extracting data from a corrupt file

I have a file located at the following location on my computer:
D:\Pictures\Imported Catalogue\Ojulari-2
I want to be able to extract the data from the (corrupt file) database file into a text file with all the SQL commands needed to recreate the database.
I'm following instructions from the following link, but I seem to be stuck executing the right command line or should I say navigation the the location of the corrupt file using the command line provided (See below)
Link to instructions I am following: http://gerhardstrasse.wordpress.com/2010/08/19/recover-from-a-corrupt-adobe-lightroom-catalog-file/
Command line I am trying to execute:
echo .dump | ./sqlite3 ~/lightroom_catalog.lrcat > ~/lightroom_catalog.sql
Download the sqlite3 command-line shell, and put the .exe file in the same directory as the database.
Open a Windows command-line shell, and go to that directory:
D:
cd "\Pictures\Imported Catalogue\Ojulari-2"
Execute:
sqlite3 MyDatabaseFile .dump > MyDatabase.sql

How to use sqlite3.exe to create database from exported .sql script

Trying to convert an SqlCe database to SQLite, I export it to a .sql file. Now how would I use sqlite.exe to create a database from this .sql file?
Where to put the sql3.exe file?
What command syntax to use, in cmd prompt or in the sqlite.exe shell?
Use following command line:
sqlite3 -init dump.sql newsqlite.db ""
It will create new SQLite database file newsqlite.db by executing statements from dump.sql. Empty string "" is needed for sqlite3 to quit automatically.
If newsqlite.db file already existed with some data, import may fail unless you use IF NOT EXISTS for all table and index creation statements.
Put sqlite3.exe wherever you want, as long as you remember that place and you're able to start sqlite3 from there.
Applying a script to a database (maybe a newly-created one), in command prompt:
sqlite3.exe my-new-db.somesuffix < myscript.sql
Executing a script within interactive sqlite3 session:
sqlite3.exe my-new-db.somesuffix
....
.read myscript.sql
....
Both variants are valid and usable at times. (Note: if your .sql was generated for non-sqlite database, I'd expect that it will require some changes to work in sqlite3. And things like stored procedures and user-defined functions will be definitely lost).

Resources