Migrate from sqlite
This commit is contained in:
parent
0d40f74503
commit
bcece8697b
|
@ -1,3 +0,0 @@
|
||||||
LOAD DATABASE
|
|
||||||
FROM mysql://odyfo:rajjout@unix:/.mysql/mysql.sock/odyfo
|
|
||||||
INTO postgresql://odyfo:rajjout@/odyfo
|
|
11
mysql.sql
11
mysql.sql
|
@ -1,11 +0,0 @@
|
||||||
CREATE DATABASE IF NOT EXISTS odyfo CHARACTER SET utf8mb4;
|
|
||||||
|
|
||||||
CREATE USER IF NOT EXISTS odyfo IDENTIFIED BY 'rajjout';
|
|
||||||
|
|
||||||
GRANT USAGE ON *.* TO odyfo@localhost IDENTIFIED BY 'rajjout';
|
|
||||||
|
|
||||||
GRANT ALL PRIVILEGES ON odyfo.* TO odyfo@localhost;
|
|
||||||
|
|
||||||
USE odyfo;
|
|
||||||
|
|
||||||
source origin_db.sql;
|
|
5
psql.sql
5
psql.sql
|
@ -1,5 +0,0 @@
|
||||||
CREATE ROLE odyfo WITH LOGIN PASSWORD 'rajjout';
|
|
||||||
|
|
||||||
CREATE DATABASE odyfo WITH OWNER odyfo;
|
|
||||||
|
|
||||||
CREATE DATABASE test_odyfo WITH OWNER odyfo;
|
|
36
shell.nix
36
shell.nix
|
@ -3,37 +3,31 @@
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
let
|
let
|
||||||
mysql_file = "mysql.sql";
|
sql_file = "psql_creation.sql";
|
||||||
psql_file = "psql.sql";
|
data_dir = "$(pwd)/.pgdata";
|
||||||
mysql_dir = "$(pwd)/.mysql";
|
origin = "odyfo.db";
|
||||||
psql_dir = "$(pwd)/.pgdata";
|
|
||||||
socket = "${mysql_dir}/mysql.sock";
|
|
||||||
|
|
||||||
in mkShell {
|
in mkShell {
|
||||||
buildInputs = [ mysql57 postgresql pgloader ];
|
buildInputs = [ postgresql pgloader ];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
trap "kill 0" EXIT
|
trap "kill 0" EXIT
|
||||||
export PGDATA="${psql_dir}"
|
export PGDATA="${data_dir}"
|
||||||
export PGHOST="${psql_dir}"
|
export PGHOST="${data_dir}"
|
||||||
|
|
||||||
# MySQL initialization
|
if [ ! -d ${data_dir} ]; then
|
||||||
if [ ! -d ${mysql_dir} ]; then
|
|
||||||
mysqld --datadir="${mysql_dir}" --socket="${socket}" --initialize-insecure
|
|
||||||
fi
|
|
||||||
mysqld --datadir="${mysql_dir}" --socket="${socket}" --skip-networking &
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
# PostgreSQL initialization
|
|
||||||
if [ ! -d ${psql_dir} ]; then
|
|
||||||
initdb --auth-local=trust --no-locale --encoding=UTF8
|
initdb --auth-local=trust --no-locale --encoding=UTF8
|
||||||
fi
|
fi
|
||||||
pg_ctl start -o "--unix_socket_directories=${psql_dir} --listen_addresses='''"
|
|
||||||
|
|
||||||
mysql --socket="${socket}" -u root < ${mysql_file}
|
if ! pg_ctl status; then
|
||||||
psql -d postgres -f ${psql_file}
|
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
|
||||||
|
fi
|
||||||
|
|
||||||
alias mysql='mysql --socket="${socket}" -u root'
|
psql -d postgres -f ${sql_file}
|
||||||
alias psql='psql -d postgres'
|
alias psql='psql -d postgres'
|
||||||
|
alias nuke='rm -rf ${data_dir}'
|
||||||
|
|
||||||
|
pgloader ${origin} postgresql:///odyfo
|
||||||
|
pg_dump odyfo > migrated_db.sql
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue