From 95850dc4f89b8fa954c922d8b8655dfbab87a668 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 9 Feb 2021 15:17:02 +0100 Subject: [PATCH] Revert "Add MySQL and alembic" This reverts commit b5d4ed519dec1836246190e5af84b4a8c4543dd4. --- mysql_creation.sql | 11 ----------- psql_creation.sql | 6 ++++-- shell.nix | 49 ++++++++++------------------------------------ 3 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 mysql_creation.sql diff --git a/mysql_creation.sql b/mysql_creation.sql deleted file mode 100644 index 298f39b..0000000 --- a/mysql_creation.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE DATABASE odyfo CHARACTER SET utf8mb4; - -CREATE DATABASE test_odyfo CHARACTER SET utf8mb4; - -USE odyfo; - -source databases/production_db.sql; - -USE test_odyfo; - -source databases/test_db.sql; diff --git a/psql_creation.sql b/psql_creation.sql index b3ccca0..d9b2a1d 100644 --- a/psql_creation.sql +++ b/psql_creation.sql @@ -1,3 +1,5 @@ -CREATE DATABASE odyfo; +CREATE ROLE odyfo WITH LOGIN PASSWORD 'rajjout'; -CREATE DATABASE test_odyfo; +CREATE DATABASE odyfo WITH OWNER odyfo; + +CREATE DATABASE test_odyfo WITH OWNER odyfo; diff --git a/shell.nix b/shell.nix index b983ce2..f3bb988 100644 --- a/shell.nix +++ b/shell.nix @@ -3,59 +3,30 @@ with pkgs; let - psql_file = "psql_creation.sql"; - psql_dir = "$(pwd)/.pgdata"; - mysql_file = "mysql_creation.sql"; - mysql_dir = "$(pwd)/.mysql"; - socket = "${mysql_dir}/mysql.sock"; - prod_origin = "mysql://root@unix:${socket}:/odyfo"; - prod_destination = "postgresql://localhost/odyfo"; - test_origin = "mysql://root@unix:${socket}:/test_odyfo"; - test_destination = "postgresql://localhost/test_odyfo"; + sql_file = "psql_creation.sql"; + data_dir = "$(pwd)/.pgdata"; + origin = "databases/odyfo.db"; in mkShell { - buildInputs = [ - postgresql - mysql57 - pgloader - python38Packages.alembic - python38Packages.pymysql - ]; + buildInputs = [ postgresql sqlite ]; shellHook = '' trap "kill 0" EXIT - export PGDATA="${psql_dir}" - export PGHOST="${psql_dir}" + export PGDATA="${data_dir}" + export PGHOST="${data_dir}" - # Initialize PostgreSQL - if [ ! -d ${psql_dir} ]; then + if [ ! -d ${data_dir} ]; then initdb --auth-local=trust --no-locale --encoding=UTF8 fi if ! pg_ctl status; then - pg_ctl start -o "--unix_socket_directories=${psql_dir} --listen_addresses='''" + pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''" fi - psql -d postgres -f ${psql_file} - - # Initialize MySQL - if [ ! -d ${mysql_dir} ]; then - mysqld --datadir="${mysql_dir}" --socket="${socket}" --initialize-insecure - fi - - mysqld --datadir="${mysql_dir}" --socket="${socket}" --skip-networking & - sleep 5 - - mysql --socket="${socket}" -u root < ${mysql_file} + psql -d postgres -f ${sql_file} alias psql='psql -d postgres' - alias mysql='mysql --socket="${socket}" -u root' - alias nuke='rm -rf ${psql_dir} ${mysql_dir}' + alias nuke='rm -rf ${data_dir}' - alembic upgrade head - pgloader ${prod_origin} ${prod_destination} - pgloader ${test_origin} ${test_destination} - pg_dump odyfo > databases/psql_prod_db.sql - pg_dump test_odyfo > databases/psql_test_db.sql ''; }