How to install flyway DB migration tool in CentOS? - flyway

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.

Related

Creating a pyinstaller executable that uses virtualenv imported modules

So, the title basically covers my question. I've created a project using virtualenv, e.g. I have to
source ./env/bin/activate
to run my script.
When I try creating an executable using:
pyinstaller --onefile <myscript.py>
None of the virtualenv packages are included; just the ones that are installed globally. I have a requirements.txt file that contains all of the modules I need. Is there a way to have pyinstaller point to that for the needed modules, or is there another way?
As Valentino pointed out by looking at How can I create the minimum size executable with pyinstaller?
You have to run PyIntaller from inside the virtual environment:
(venv_test) D:\testenv>pyinstaller
How to solve the not importing modules from the virtual environment
The virtual environment saves modules in a different directory than the global module directory. If you are using Windows like me, you can find the modules directory here:
C:\Users\<your username>\.virtualenvs\<your project name>\Lib\site-packages
When you find your virtualenv directory, run this command instead of this simple command(pyinstaller <script>.py):
pyinstaller --paths "C:\Users\<your username>\.virtualenvs\<your project name>\Lib\site-packages" --hidden-import <module name that should be import> <your script name>.py
To export just one file you can add this: -F or --onefile
As many modules as you can add to be imported by adding more --hidden-import flags and module name
Flag description
--paths: The pyinstaller will search for imports here
--hidden-import: Which modules should be imported by pyinstaller from the path

Grunt won't run even though installed globally and locally

After following these instructions to allow installation of npm packages without sudo, I've run into some problems. Currently, I'm unable to run Grunt.
I've installed Grunt both locally and globally. But when I type grunt within my project, I get the following error:
-bash: grunt: command not found
When I check npm list -g, I get the following:
/Users/user1/.npm-packages/lib
├── grunt#0.4.5
├── grunt-cli#0.1.13
Grunt is also listed (grunt#0.4.5) when I use npm list in my local project.
My .bashrc file looks like this:
NPM_PACKAGES="/Users/user1/.npm-packages"
#export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
Any ideas what I might be doing wrong?

How to add source files to an external project in CMake?

I want to integrate SQLite into my project using ExternalProject_Add.
cmake_minimum_required(VERSION 2.8.8)
include(ExternalProject)
# Download, configure, build and install SQLite
ExternalProject_Add(SQLite
PREFIX ${CMAKE_SOURCE_DIR}
TMP_DIR ${CMAKE_SOURCE_DIR}/temp
STAMP_DIR ${CMAKE_SOURCE_DIR}/stamp
#--Download step--------------
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
URL http://www.sqlite.org/2014/sqlite-autoconf-3080704.tar.gz
URL_HASH SHA1=70ca0b8884a6b145b7f777724670566e2b4f3cde
#--Update/Patch step----------
UPDATE_COMMAND ""
#--Configure step-------------
SOURCE_DIR ${CMAKE_SOURCE_DIR}/source
CONFIGURE_COMMAND "" # How to add sqlite3.c to the target here?
#--Build step-----------------
BINARY_DIR ${CMAKE_SOURCE_DIR}/build
BUILD_COMMAND "cmake --build ."
#--Install step---------------
INSTALL_DIR ${CMAKE_SOURCE_DIR}/install
)
The build command would use the native compiler to build all source files added to the target SQLite. However, there are non. How can I add the only source file sqlite3.c to the external project within the CONFIGURE_COMMAND?
ExternalProject_Add assumes that the project you want to pull in already ships with a (possibly complex, possibly non-CMake-based) working build system.
You have two possibilities here:
You can stick with the amalgamated autoconf version of sqlite that you are currently using. In that case the CONFIGURE_COMMAND would invoke configure and the BUILD_COMMAND would invoke make. Note that this approach will not be portable to platforms that do not have autoconf installed.
You can switch to the bare-source amalgamated version of sqlite and provide your own CMakeLists.txt for building. Since sqlite can be built with a minimum of configuration and the amalgamation only consists of a single source and header file, this is not as hard as it may sound. In this case you can simply invoke cmake for configuation and building.
Note however that you cannot provide this information in-line with ExternalProject_Add. You will need an external build script, whether that is CMake, autoconf or something else.
Building on the correct answer above, this is what I came up with. Instead of adding a second file to my repository, it gets generated from the existing CMake file. Since the source directory of the external project gets cleaned on build, the generated file must be stored in a temporary location and copied into the source directory in a later step of the external project, in this case the update command.
# SQLite
cmake_minimum_required(VERSION 2.8.8)
include(ExternalProject)
# Add CMake project file
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/temp)
file(WRITE ${CMAKE_SOURCE_DIR}/temp/CMakeLists.txt
"cmake_minimum_required(VERSION 2.8.8)\n"
"set(PROJECT_NAME sqlite)\n"
"include_directories(${CMAKE_SOURCE_DIR}/source)\n"
"add_library(sqlite3 ${CMAKE_SOURCE_DIR}/source/sqlite3.c)\n"
"install(TARGETS sqlite3 DESTINATION lib)\n"
"install(FILES sqlite3.h DESTINATION include)\n")
# Download, configure, build and install.
ExternalProject_Add(SQLite
# DEPENDS
PREFIX ${CMAKE_SOURCE_DIR}
TMP_DIR ${CMAKE_SOURCE_DIR}/temp
STAMP_DIR ${CMAKE_SOURCE_DIR}/stamp
#--Download step--------------
DOWNLOAD_DIR ${SFML_PREFIX}/download
URL http://www.sqlite.org/2014/sqlite-autoconf-3080704.tar.gz
URL_HASH SHA1=70ca0b8884a6b145b7f777724670566e2b4f3cde
#--Update/Patch step----------
UPDATE_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/temp/CMakeLists.txt
${CMAKE_SOURCE_DIR}/source/CMakeLists.txt
#--Configure step-------------
SOURCE_DIR ${CMAKE_SOURCE_DIR}/source
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_SOURCE_DIR}/install
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
#--Build step-----------------
BINARY_DIR ${CMAKE_SOURCE_DIR}/build
BUILD_COMMAND ${CMAKE_COMMAND} --build .
#--Install step---------------
INSTALL_DIR ${CMAKE_SOURCE_DIR}/install
)

Execute liquibase update in production environment

I have a Java Maven project. I'm using liquibase to update DB.
Locally, to update my db, I just run in command line:
mvn liquibase:update
In production environment, I don't have Maven installed.
What I need to achieve is through console, execute a command to run the liquibase scripts in a specific classpath.
Any ideas?
Edit:
Ok.I'm trying to follow this approach. I put in a folder the following items:
liquibase jar
The war containing my application and the liquibase changesets
liquibase.properties: It contains the following:
url=jdbc:jtds:sqlserver://xxxxxxxx:xxxx/xxxxx
username=xxx
password=xxxxx
classpath=war_file.war
changeLogFile=WEB-INF/classes/sql/projectName/liquibase/liquibase.xml
Then, in a console, I execute:
java -jar liquibase-core-3.0.5.jar update
It works! It finds my liquibase.xml file and starts the liquibase update.
BUT, when it refers to liquibase.xml that are inside another jar file included in the lib, it fails, because I included it in the liquibase.xml as:
<include file="../other_module/src/main/resources/sql/projectName/liquibase/liquibase.xml" />
How can I add this "include" without doing "src/main/resources" and make it find this xml?
Running the updateSQL goal on your Dev machine:
mvn liquibase:updateSQL
You can generate a migration script:
└── target
└── liquibase
└── migrate.sql
This is one of my favourite features of liquibase. Sometimes clients insist that all database schema changes must be performed manually by their staff.
Another option is to build an auto-upgrade capability into your application. See the servlet listener

Implementing a selected unix path for a specific application (e.g. pytest)

I have two versions of pytest installed, one locally in a directory in my home directory, and one that is installed in /usr/local/bin.
The version of pytest installed in the /usr/local/bin is 2.2.4 and I don't have sudo rights to upgrade it to the newer version, 2.3.4, but need some tests to run with 2.3.4.
Is there a way to redirect the path so that it always uses the pytest in my home directory over the pytest in the /usr/local/bin directory when I invoke pytest?
Because there is a need to run many tests, it would be more convenient to have a shortcut!
You should add a directory to your $PATH that contains the copy of pytest you would like to use. For example, place pytest in ~/bin and add ~/bin (or $HOME/bin) to your path:
PATH="$HOME/bin:$PATH"
export PATH
As indicated, place the new directory at the front of the path so that your copy of pytest (and whatever else you put in ~/bin) will be found first.
Even better, put those two lines into ~/.profile so that your $PATH will be updated every time you log in.

Resources