Browse Source

Detach legacy migration settings and requirements

pull/6/head
Marcio Mazza 10 years ago
parent
commit
33b97b2426
  1. 10
      legacy/migration.py
  2. 6
      legacy/run_legacy_tests.sh
  3. 1
      pytest.ini
  4. 2
      requirements/migration-requirements.txt
  5. 1
      requirements/requirements.txt
  6. 18
      sapl/legacy_migration_settings.py
  7. 14
      sapl/settings.py
  8. 2
      sapl/test_general.py
  9. 13
      sapl/utils.py

10
legacy/migration.py

@ -11,19 +11,11 @@ from model_mommy import mommy
from comissoes.models import Composicao, Participacao
from parlamentares.models import Parlamentar
from sapl.utils import appconfs
# BASE ######################################################################
# this order is important for the migration
appconfs = [apps.get_app_config(n) for n in [
'parlamentares',
'comissoes',
'materia',
'norma',
'sessao',
'lexml',
'protocoloadm', ]]
name_sets = [set(m.__name__ for m in ac.get_models()) for ac in appconfs]
# apps do not overlap

6
legacy/run_legacy_tests.sh

@ -0,0 +1,6 @@
#!/bin/bash
# All tests under this directory are excluded in default pytest.ini
# To run them use this script in this directory
py.test --ds=sapl.legacy_migration_settings

1
pytest.ini

@ -1,5 +1,6 @@
[pytest]
DJANGO_SETTINGS_MODULE=sapl.settings
norecursedirs = legacy
# REUSING DATABASE BY DEFAULT (as a performance optimization)
# http://pytest-django.readthedocs.org/en/latest/database.html#example-work-flow-with-reuse-db-and-create-db

2
requirements/migration-requirements.txt

@ -0,0 +1,2 @@
-r dev-requirements.txt
mysqlclient

1
requirements/requirements.txt

@ -3,7 +3,6 @@ django-admin-bootstrapped
django-bootstrap3
django-braces
django-crispy-forms
mysqlclient
psycopg2
pytz
PyYAML

18
sapl/legacy_migration_settings.py

@ -0,0 +1,18 @@
# Settings for data migration from mysql legacy to new postgres database
from .settings import *
INSTALLED_APPS += (
'legacy', # legacy reversed model definitions
)
DATABASES['legacy'] = {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sapl25',
'USER': 'root',
'PASSWORD': 'admin',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
DATABASE_ROUTERS = ['legacy.router.LegacyRouter', ]

14
sapl/settings.py

@ -39,9 +39,6 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
# legacy reversed model definitions (temporary)
'legacy',
# sapl modules
'base',
'parlamentares',
@ -89,7 +86,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'sapl.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
@ -101,19 +97,9 @@ DATABASES = {
'PASSWORD': 'sapl',
'HOST': 'localhost',
'PORT': '5432',
},
'legacy': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sapl25',
'USER': 'root',
'PASSWORD': 'admin',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
DATABASE_ROUTERS = ['legacy.router.LegacyRouter', ]
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'pt-br'

2
sapl/test_general.py

@ -1,7 +1,7 @@
import pytest
from model_mommy import mommy
from legacy.migration import appconfs
from .utils import appconfs
pytestmark = pytest.mark.django_db

13
sapl/utils.py

@ -2,6 +2,19 @@ from django.apps import apps
from django.contrib import admin
# SAPL business apps
# This is a dependency order: each entry depends only on previous ones
# The order is important for migration code
appconfs = [apps.get_app_config(n) for n in [
'parlamentares',
'comissoes',
'materia',
'norma',
'sessao',
'lexml',
'protocoloadm', ]]
def register_all_models_in_admin(module_name):
appname = module_name.split('.')[0]
app = apps.get_app_config(appname)

Loading…
Cancel
Save