From bef332175398822179f7ef9e9fb1598a4bb93ea7 Mon Sep 17 00:00:00 2001
From: dcz <dcz@ipipan.waw.pl>
Date: Mon, 4 Apr 2022 15:28:52 +0200
Subject: [PATCH] =?UTF-8?q?Zmiany=20poptrzebne=20do=20=C5=82adowania=20baz?=
 =?UTF-8?q?y?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../management/commands/import_expansions.py  |  2 +-
 reset_db.sh                                   | 29 +++++++++++++++----
 syntax/management/commands/import_tei.py      |  2 +-
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/phrase_expansions/management/commands/import_expansions.py b/phrase_expansions/management/commands/import_expansions.py
index 002271f..ebf2c08 100644
--- a/phrase_expansions/management/commands/import_expansions.py
+++ b/phrase_expansions/management/commands/import_expansions.py
@@ -28,7 +28,7 @@ OPINION_MAP = {
 }
 
 def import_expansions():
-    xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'phrase_types_expand_20200926.xml')
+    xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'phrase_types_expand_20210913.xml')
     xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), xml_file)
     
     parser = make_parser()
diff --git a/reset_db.sh b/reset_db.sh
index 7352ed9..c3b1cc4 100755
--- a/reset_db.sh
+++ b/reset_db.sh
@@ -1,8 +1,27 @@
 #!/bin/bash
 
-dropdb shellvalier
-createdb shellvalier -E UTF8 -T template0 -l pl_PL.utf8
-python3 manage.py migrate
-python3 manage.py import_plWordnet
-python3 manage.py import_tei
+sudo su postgres -c "dropdb shellvalier"
+sudo su postgres -c "createdb shellvalier -E UTF8 -T template0 -l pl_PL.utf8"
 
+# reset the migrations since we create the DB from scratch
+find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
+find . -path "*/migrations/*.pyc"  -delete
+
+python manage.py makemigrations
+python manage.py migrate
+
+rm import.log
+
+time python manage.py start_import
+time python manage.py import_expansions
+time python manage.py import_plWordnet
+time python manage.py import_tei
+
+head import.log
+wc import.log
+
+#python manage.py check_descriptions
+python manage.py generate_semantics_css
+
+# TODO dev only!!!
+python manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('shell', '', 'valier')"
diff --git a/syntax/management/commands/import_tei.py b/syntax/management/commands/import_tei.py
index 1d6a861..da37586 100644
--- a/syntax/management/commands/import_tei.py
+++ b/syntax/management/commands/import_tei.py
@@ -32,7 +32,7 @@ def import_tei():
     logging.basicConfig(filename='import.log', level=logging.DEBUG)
 
     #xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'walenty_20200926_smaller.xml')
-    xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'walenty_20200926.xml')
+    xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'walenty_20210913_smaller.xml')
 
     xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), xml_file)
 
-- 
GitLab