diff --git a/docs/database-pgsql-setup.txt b/docs/database-pgsql-setup.txt new file mode 100644 index 0000000000000000000000000000000000000000..b823a5e0e5c9ef659727cc9470dac5574098acc0 --- /dev/null +++ b/docs/database-pgsql-setup.txt @@ -0,0 +1,50 @@ +# Setting up pgsql base + 1. install linked packages + 2. Set up new postgresql db & adapt settings.py + 3. run migrate + good docs : + https://hevodata.com/learn/sqlite-to-postgresql/ + https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-django-application-on-ubuntu-20-04 + + issues with id range will rise, run command in pgsql: + psql or sudo -u postgres psql + alter table risefor_lobbying_missionParlementaire alter column id type bigint; + alter sequence "public.risefor_lobbying_missionParlementaire_id_seq" as bigint; + alter table risefor_lobbying_groupeEtude alter column id type bigint; + alter sequence public.risefor_lobbying_groupeEtude_id_seq as bigint; + + + alter table "risefor_lobbying_representative_parliamentaryMissions" alter column id,missionparlementaire_id type bigint; + alter table "risefor_lobbying_representative_parliamentaryMissions" alter column representative_id type bigint; + alter table "risefor_lobbying_representative_parliamentaryMissions" alter column missionparlementaire_id type bigint; + alter sequence public.risefor_lobbying_representative_parliamentary_missions_id_seq as bigint; + alter table "risefor_lobbying_representative_studyGroups" alter column id type bigint; + alter sequence public.risefor_lobbying_representative_study_groups_id_seq as bigint; + + + alter table "risefor_lobbying_representative_studyGroups" alter column id, type bigint; + alter table "risefor_lobbying_representative_studyGroups" alter column representative_id type bigint; + alter table "risefor_lobbying_representative_studyGroups" alter column groupeetude_id type bigint; + + + representative_id + missionparlementaire_id + + + + +# Process to migrate from sqlite3 to postgresql + Migration : + - export data (make sure site is using database you want to migrate) + python3 manage.py dumpdata > site-export.json + + - change settings.py to new database + + - Remove content type if a migration occured to avoid errors : + python3 manage.py shell + from django.contrib.contenttypes.models import ContentType + ContentType.objects.all().delete() + + + - upload data + python3 manage.py loaddata site-export.json diff --git a/requirements.txt b/requirements.txt index 9aa6f63eacdebdc18a8d10d5013a1e2cbe5f286b..e7e89616610852a64192a37ced2a0d6d00b2ed49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,10 @@ +# wheel alabaster==0.7.12 Beaker==1.11.0 certifi==2019.11.28 cffi==1.14.0 +asgiref +# cffi chardet==3.0.4 Click==7.0 confusable-homoglyphs==3.2.0 @@ -43,3 +46,6 @@ validators==0.14.2 django_countries Pillow unidecode + +#for postgresql db +psycopg2-binary==2.9 diff --git a/united4earth/server/settings_sample.py b/united4earth/server/settings_sample.py index dc1ef9c85fabb95b7afbf249988237550b33e785..c021c30c7f99ef665a482a6b724dc6664b9bd4e4 100644 --- a/united4earth/server/settings_sample.py +++ b/united4earth/server/settings_sample.py @@ -144,26 +144,29 @@ TEMPLATES = [ }, ] -# Database -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), +dataBaseType = 'dev or postgresql' +if dataBaseType == 'dev': + # Database + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } } -} -""" -#use other db -DATABASES = { +#use other db +elif dataBaseType == 'postgresql': + DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': '', - 'USER': '', - 'PASSWORD': '', - 'HOST': '', - 'PORT': '', + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'database_name', + 'USER': 'user_name', + 'PASSWORD': 'user_password', + 'HOST': 'backend_url', + 'PORT': '', + } } -} -""" +else: + raise ValueError("Choose type of database :",dataBaseType," in file settings.py") # Authentication diff --git a/united4earth/static/scss/src/_action-group-detail.scss b/united4earth/static/scss/src/_action-group-detail.scss index 91b06648836302fea41121f3604f2e552df202ff..344f3e9490a1715a48f959c5d6ff49c1fda2063c 100644 --- a/united4earth/static/scss/src/_action-group-detail.scss +++ b/united4earth/static/scss/src/_action-group-detail.scss @@ -27,6 +27,8 @@ width: 90%; left:5%; transform: translateX(0%); + display: flex; + align-self: center; } }