Просмотр исходного кода

Mysql + Postgres compatibility

Bastien Sevajol 8 лет назад
Родитель
Сommit
0754c021e7
3 измененных файлов: 23 добавлений и 20 удалений
  1. 22 18
      .travis.yml
  2. 1 1
      tracim/development.ini.base
  3. 0 1
      tracim/tracim/model/__init__.py

+ 22 - 18
.travis.yml Просмотреть файл

@@ -1,30 +1,34 @@
1 1
 sudo: false
2 2
 language: python
3
-python:
4
-#  - "3.2"
5
-#  - "3.3"
6
-  - "3.4"
3
+python: "3.4"
4
+
5
+env:
6
+  - DB=postgres
7
+  - DB=mysql
7 8
 
8 9
 addons:
9 10
   postgresql: "9.3"
11
+  mysql: "5.5"
10 12
 
11
-# command to install dependencies
12
-# Note: there's an echo at the end of pip install. It allows to override the default return code which is not 0
13
-# because some packages need to be ugraded to python3 (invalid python syntax because of python2 source code)
14
-#
15
-# pip install -r is run 2 times in order to really install tgapp-resetpassword (to investigate)
16
-#
17 13
 install:
18
-  - "cd tracim && python setup.py develop; cd -"
19
-  - "pip install -r install/requirements.txt; echo"
20
-  - "pip install coveralls"
14
+  - cd tracim && python setup.py develop; cd -
15
+  - pip install -r install/requirements.txt; echo
16
+  - pip install coveralls
21 17
 
22 18
 before_script:
23
-  - "psql -c 'create database tracim_test;' -U postgres"
24
-  - "cp ${TRAVIS_BUILD_DIR}/tracim/development.ini.base ${TRAVIS_BUILD_DIR}/tracim/development.ini"
25
-#  - "cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app -c ${TRAVIS_BUILD_DIR}/tracim/test.ini"
26
-  - "cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app"
27
-#  - "cd ${TRAVIS_BUILD_DIR}/tracim && gearbox migrate -c ${TRAVIS_BUILD_DIR}/tracim/test.ini upgrade"
19
+  - cp ${TRAVIS_BUILD_DIR}/tracim/development.ini.base ${TRAVIS_BUILD_DIR}/tracim/development.ini
20
+
21
+  - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database tracim_test;' -U postgres; fi"
22
+  - sh -c "if [ '$DB' = 'postgres' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/\(sqlalchemy.url *= *\).*/\1postgresql:\/\/postgres:dummy@127.0.0.1:5432\/tracim_test?client_encoding=utf8/\" test.ini; fi"
23
+  - sh -c "if [ '$DB' = 'postgres' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/\(sqlalchemy.url *= *\).*/\1postgresql:\/\/postgres:dummy@127.0.0.1:5432\/tracim_test?client_encoding=utf8/\" development.ini; fi"
24
+
25
+  - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE tracim_test;'; fi"
26
+  - sh -c "if [ '$DB' = 'mysql' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/\(sqlalchemy.url *= *\).*/\mysql+oursql:\/\/root@localhost\/tracim_test/\" test.ini; fi"
27
+  - sh -c "if [ '$DB' = 'mysql' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/<replace_database_uri_here>/mysql+oursql:\/\/root@localhost\/tracim_test/\" development.ini; fi"
28
+  - sh -c "if [ '$DB' = 'mysql' ]; then pip install https://launchpad.net/oursql/py3k/py3k-0.9.4/+download/oursql-0.9.4.zip; fi"
29
+
30
+  - cd ${TRAVIS_BUILD_DIR}/tracim && cat development.ini | grep sqlalchemy
31
+  - cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app --debug
28 32
 
29 33
 # command to run tests
30 34
 script: "cd ${TRAVIS_BUILD_DIR}/tracim && nosetests -c ${TRAVIS_BUILD_DIR}/tracim/test.ini -v --with-coverage --cover-package=tracim --cover-erase"

+ 1 - 1
tracim/development.ini.base Просмотреть файл

@@ -92,7 +92,7 @@ beaker.session.validate_key = 3283411b-1904-4554-b0e1-883863b53080
92 92
 # sqlalchemy.url=postgresql://username:password@hostname:port/databasename
93 93
 # sqlalchemy.url=mysql://username:password@hostname:port/databasename
94 94
 # sqlalchemy.url = postgresql://tracim_user:tracim_user_password@127.0.0.1:5432/tracim?client_encoding=utf8
95
-sqlalchemy.url = postgresql://postgres:dummy@127.0.0.1:5432/tracim_test?client_encoding=utf8
95
+sqlalchemy.url = <replace_database_uri_here>
96 96
 
97 97
 #echo shouldn't be used together with the logging module.
98 98
 sqlalchemy.echo = false

+ 0 - 1
tracim/tracim/model/__init__.py Просмотреть файл

@@ -49,7 +49,6 @@ DBSession = scoped_session(maker)
49 49
 convention = {
50 50
   "ix": 'ix__%(column_0_label)s',  # Indexes
51 51
   "uq": "uq__%(table_name)s__%(column_0_name)s",  # Unique constrains
52
-  "ck": "ck__%(table_name)s__%(constraint_name)s",  # Other column constrains
53 52
   "fk": "fk__%(table_name)s__%(column_0_name)s__%(referred_table_name)s",  # Foreign keys
54 53
   "pk": "pk__%(table_name)s"  # Primary keys
55 54
 }