misc: drop sqlite support - postgresql only (#56148)
This commit is contained in:
parent
402438f4df
commit
16487b34bb
|
@ -1,7 +1,6 @@
|
|||
*.pyc
|
||||
*.mo
|
||||
local_settings.py
|
||||
/db.sqlite3
|
||||
/dist
|
||||
/chrono.egg-info
|
||||
/chrono/manager/static/css/style.css
|
||||
|
|
2
README
2
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).
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
},
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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)
|
||||
|
|
3
tox.ini
3
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
|
||||
|
|
Loading…
Reference in New Issue