Browse Source

Add support for SQL Server database

pull/255/head
Clemens Wolff 6 years ago
parent
commit
47bbb741d2
6 changed files with 42 additions and 5 deletions
  1. 11
      Dockerfile
  2. 4
      app/api/migrations/0001_initial.py
  3. 24
      app/api/migrations/0003_support_sql_server.py
  4. 2
      app/api/models.py
  5. 5
      app/app/settings.py
  6. 1
      requirements.txt

11
Dockerfile

@ -5,6 +5,8 @@ ARG NODE_VERSION="8.x"
RUN curl -sL "https://deb.nodesource.com/setup_${NODE_VERSION}" | bash - \
&& apt-get install nodejs
RUN apt-get install -y unixodbc-dev
COPY app/server/static/package*.json /doccano/app/server/static/
RUN cd /doccano/app/server/static \
&& npm ci
@ -29,6 +31,15 @@ RUN cd /doccano \
FROM python:${PYTHON_VERSION}-slim-stretch AS runtime
RUN apt-get update \
&& apt-get install -y curl gnupg apt-transport-https \
&& curl -fsS https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl -fsS https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools \
&& apt-get remove -y curl gnupg apt-transport-https \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -ms /bin/sh doccano
COPY --from=builder /deps /deps

4
app/api/migrations/0001_initial.py

@ -161,10 +161,6 @@ class Migration(migrations.Migration):
name='sequenceannotation',
unique_together={('document', 'user', 'label', 'start_offset', 'end_offset')},
),
migrations.AlterUniqueTogether(
name='seq2seqannotation',
unique_together={('document', 'user', 'text')},
),
migrations.AlterUniqueTogether(
name='label',
unique_together={('project', 'text'), ('project', 'prefix_key', 'suffix_key')},

24
app/api/migrations/0003_support_sql_server.py

@ -0,0 +1,24 @@
# Generated by Django 2.1.7 on 2019-06-26 13:20
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('api', '0002_approve_document_labels'),
]
operations = [
migrations.AlterField(
model_name='seq2seqannotation',
name='text',
field=models.CharField(max_length=500),
),
migrations.AlterUniqueTogether(
name='seq2seqannotation',
unique_together={('document', 'user', 'text')},
),
]

2
app/api/models.py

@ -226,7 +226,7 @@ class SequenceAnnotation(Annotation):
class Seq2seqAnnotation(Annotation):
document = models.ForeignKey(Document, related_name='seq2seq_annotations', on_delete=models.CASCADE)
text = models.TextField()
text = models.CharField(max_length=500)
class Meta:
unique_together = ('document', 'user', 'text')

5
app/app/settings.py

@ -254,6 +254,11 @@ DATABASES['default'].update(dj_database_url.config(
if DATABASES['default'].get('ENGINE') == 'django.db.backends.sqlite3':
DATABASES['default'].get('OPTIONS', {}).pop('sslmode', None)
# default to a sensible modern driver for Azure SQL
if DATABASES['default'].get('ENGINE') == 'sql_server.pyodbc':
db_options = DATABASES['default'].setdefault('OPTIONS', {})\
.setdefault('driver', 'ODBC Driver 17 for SQL Server')
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

1
requirements.txt

@ -9,6 +9,7 @@ django-heroku==0.3.1
django-webpack-loader==0.6.0
django-widget-tweaks==1.4.2
django-polymorphic==2.0.3
django-pyodbc-azure==2.1.0.0
django-rest-polymorphic==0.1.8
djangorestframework==3.8.2
djangorestframework-csv==2.1.0

Loading…
Cancel
Save