misc: drop sqlite support - postgresql only (#56148)

This commit is contained in:
Lauréline Guérin 2021-08-13 11:46:44 +02:00
parent 402438f4df
commit 16487b34bb
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
10 changed files with 13 additions and 32 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
*.pyc
*.mo
local_settings.py
/db.sqlite3
/dist
/chrono.egg-info
/chrono/manager/static/css/style.css

2
README
View File

@ -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).

View File

@ -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:

View File

@ -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:

View File

@ -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',
}
}

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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

View File

@ -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],
},

View File

@ -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',

View File

@ -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)

View File

@ -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