diff --git a/.gitignore b/.gitignore index 83e8f8f0..c6dd879a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.pyc *.mo local_settings.py -/db.sqlite3 /dist /chrono.egg-info /chrono/manager/static/css/style.css diff --git a/README b/README index fd8295e3..084be019 100644 --- a/README +++ b/README @@ -13,7 +13,7 @@ Dependencies can be installed with pip, $ pip install -r requirements.txt It's then required to get the database configured (./manage.py migrate); by -default it will create a db.sqlite3 file. +default it will create a postgresqsl DB. You can then run the Django test server for a quick try (you should refer to the Django documentation for production deployments). diff --git a/chrono/agendas/migrations/0052_event_date_range_constraint.py b/chrono/agendas/migrations/0052_event_date_range_constraint.py index b806f673..33c9cfb5 100644 --- a/chrono/agendas/migrations/0052_event_date_range_constraint.py +++ b/chrono/agendas/migrations/0052_event_date_range_constraint.py @@ -102,8 +102,6 @@ class Migration(migrations.Migration): operations = [migrations.RunSQL(sql=sql_forwards, reverse_sql=sql_backwards)] def _check_db(self, project_state, schema_editor): - if schema_editor.connection.vendor != 'postgresql': - return project_state try: with transaction.atomic(): try: diff --git a/chrono/agendas/migrations/0053_event_date_range_constraint.py b/chrono/agendas/migrations/0053_event_date_range_constraint.py index 5516dd8d..e187ba25 100644 --- a/chrono/agendas/migrations/0053_event_date_range_constraint.py +++ b/chrono/agendas/migrations/0053_event_date_range_constraint.py @@ -22,8 +22,6 @@ class Migration(migrations.Migration): operations = [migrations.RunSQL(sql=sql_forwards, reverse_sql=sql_backwards)] def _check_db(self, project_state, schema_editor): - if schema_editor.connection.vendor != 'postgresql': - return project_state try: with transaction.atomic(): try: diff --git a/chrono/settings.py b/chrono/settings.py index 8e7740a4..a6ce48bf 100644 --- a/chrono/settings.py +++ b/chrono/settings.py @@ -82,8 +82,7 @@ WSGI_APPLICATION = 'chrono.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'ENGINE': 'django.db.backends.postgresql_psycopg2', } } diff --git a/chrono/utils/db.py b/chrono/utils/db.py index 2d597859..d8dae1f2 100644 --- a/chrono/utils/db.py +++ b/chrono/utils/db.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.db import connection from django.db.migrations.operations.base import Operation @@ -30,17 +29,16 @@ class EnsureJsonbType(Operation): pass def database_forwards(self, app_label, schema_editor, from_state, to_state): - if connection.vendor == 'postgresql': - model = from_state.apps.get_model(app_label, self.model_name) - table_name = model._meta.db_table - field = model._meta.get_field(self.field_name) - _, column_name = field.get_attname_column() - with schema_editor.connection.cursor() as cursor: - cursor.execute( - 'ALTER TABLE {table} ALTER COLUMN {col} TYPE jsonb USING {col}::jsonb;'.format( - table=table_name, col=column_name - ) + model = from_state.apps.get_model(app_label, self.model_name) + table_name = model._meta.db_table + field = model._meta.get_field(self.field_name) + _, column_name = field.get_attname_column() + with schema_editor.connection.cursor() as cursor: + cursor.execute( + 'ALTER TABLE {table} ALTER COLUMN {col} TYPE jsonb USING {col}::jsonb;'.format( + table=table_name, col=column_name ) + ) def database_backwards(self, app_label, schema_editor, from_state, to_state): pass diff --git a/tests/settings.py b/tests/settings.py index dfd08408..1e527f07 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -10,7 +10,7 @@ REST_FRAMEWORK = { DATABASES = { 'default': { - 'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'), + 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'TEST': { 'NAME': 'chrono-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:63], }, diff --git a/tests/test_ensure_jsonbfields.py b/tests/test_ensure_jsonbfields.py index 24b48289..2a4515a4 100644 --- a/tests/test_ensure_jsonbfields.py +++ b/tests/test_ensure_jsonbfields.py @@ -5,7 +5,6 @@ from django.db import connection pytestmark = pytest.mark.django_db -@pytest.mark.skipif(connection.vendor != 'postgresql', reason='only postgresql is supported') def test_ensure_jsonb_fields(): json_fields = ( 'extra_data', diff --git a/tests/test_misc.py b/tests/test_misc.py index 4fa37def..678f5450 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -31,9 +31,6 @@ def check_end_datetime(event, value): def test_event_ignore_reason(): - if connection.vendor != 'postgresql': - pytest.skip('postgresql required') - agenda = Agenda.objects.create(label='Meetings', kind='meetings') meeting_type = MeetingType.objects.create(agenda=agenda, label='Foo', duration=60) desk = Desk.objects.create(agenda=agenda, label='Desk') @@ -62,9 +59,6 @@ def test_event_ignore_reason(): def test_event_end_datetime(): - if connection.vendor != 'postgresql': - pytest.skip('postgresql required') - agenda = Agenda.objects.create(label='Meetings', kind='meetings') meeting_type1 = MeetingType.objects.create(agenda=agenda, label='Foo', duration=60) meeting_type2 = MeetingType.objects.create(agenda=agenda, label='Foo', duration=45) @@ -101,9 +95,6 @@ def test_event_end_datetime(): def test_meeting_event_exclusion_constraint(): - if connection.vendor != 'postgresql': - pytest.skip('postgresql required') - agenda = Agenda.objects.create(label='Meetings', kind='meetings') meeting_type1 = MeetingType.objects.create(agenda=agenda, label='Foo 1', duration=60) meeting_type2 = MeetingType.objects.create(agenda=agenda, label='Foo 2', duration=30) diff --git a/tox.ini b/tox.ini index 603a17ae..3bc82e77 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3-django22-pg-codestyle-coverage-pylint +envlist = py3-django22-codestyle-coverage-pylint toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/chrono/{env:BRANCH_NAME:} [testenv] @@ -12,7 +12,6 @@ setenv = BRANCH_NAME={env:BRANCH_NAME:} SETUPTOOLS_USE_DISTUTILS=stdlib coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=chrono/ - pg: DB_ENGINE=django.db.backends.postgresql_psycopg2 deps = pytest-cov pytest-django