Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
0ba92ca0
Commit
0ba92ca0
authored
Oct 05, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB] Alembic: enable whole auto-detection feature
parent
0f3ecfc8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
env.py
alembic/env.py
+10
-8
base.py
gargantext/models/base.py
+11
-1
No files found.
alembic/env.py
View file @
0ba92ca0
...
@@ -52,6 +52,14 @@ def include_object(obj, name, typ, reflected, compare_to):
...
@@ -52,6 +52,14 @@ def include_object(obj, name, typ, reflected, compare_to):
return
True
return
True
context_opts
=
dict
(
target_metadata
=
target_metadata
,
include_object
=
include_object
,
compare_server_default
=
True
,
compare_type
=
True
,
)
def
run_migrations_offline
():
def
run_migrations_offline
():
"""Run migrations in 'offline' mode.
"""Run migrations in 'offline' mode.
...
@@ -65,9 +73,7 @@ def run_migrations_offline():
...
@@ -65,9 +73,7 @@ def run_migrations_offline():
"""
"""
url
=
config
.
get_main_option
(
"sqlalchemy.url"
)
url
=
config
.
get_main_option
(
"sqlalchemy.url"
)
context
.
configure
(
context
.
configure
(
url
=
url
,
literal_binds
=
True
,
**
context_opts
)
url
=
url
,
target_metadata
=
target_metadata
,
literal_binds
=
True
,
include_object
=
include_object
)
with
context
.
begin_transaction
():
with
context
.
begin_transaction
():
context
.
run_migrations
()
context
.
run_migrations
()
...
@@ -86,11 +92,7 @@ def run_migrations_online():
...
@@ -86,11 +92,7 @@ def run_migrations_online():
poolclass
=
pool
.
NullPool
)
poolclass
=
pool
.
NullPool
)
with
connectable
.
connect
()
as
connection
:
with
connectable
.
connect
()
as
connection
:
context
.
configure
(
context
.
configure
(
connection
=
connection
,
**
context_opts
)
connection
=
connection
,
target_metadata
=
target_metadata
,
include_object
=
include_object
)
with
context
.
begin_transaction
():
with
context
.
begin_transaction
():
context
.
run_migrations
()
context
.
run_migrations
()
...
...
gargantext/models/base.py
View file @
0ba92ca0
from
sqlalchemy.schema
import
Column
,
ForeignKey
,
UniqueConstraint
,
Index
from
sqlalchemy.schema
import
Column
,
ForeignKey
,
UniqueConstraint
,
Index
from
sqlalchemy.orm
import
relationship
,
validates
from
sqlalchemy.orm
import
relationship
,
validates
from
sqlalchemy.types
import
TypeDecorator
,
\
from
sqlalchemy.types
import
TypeDecorator
,
\
Integer
,
Float
,
Boolean
,
DateTime
,
String
,
Text
Integer
,
REAL
,
Boolean
,
DateTime
,
String
,
Text
from
sqlalchemy_utils.types
import
TSVectorType
from
sqlalchemy_utils.types
import
TSVectorType
from
sqlalchemy.dialects.postgresql
import
JSONB
,
DOUBLE_PRECISION
as
Double
from
sqlalchemy.dialects.postgresql
import
JSONB
,
DOUBLE_PRECISION
as
Double
from
sqlalchemy.ext.mutable
import
MutableDict
,
MutableList
from
sqlalchemy.ext.mutable
import
MutableDict
,
MutableList
...
@@ -27,6 +27,16 @@ Base = declarative_base()
...
@@ -27,6 +27,16 @@ Base = declarative_base()
DjangoBase
=
declarative_base
()
DjangoBase
=
declarative_base
()
class
Float
(
REAL
):
"""Reflect exact REAL type for PostgreSQL in order to avoid confusion
within Alembic type comparison"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
kwargs
.
get
(
'precision'
)
==
24
:
kwargs
.
pop
(
'precision'
)
super
(
Float
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
class
ValidatorMixin
(
object
):
class
ValidatorMixin
(
object
):
def
enforce_length
(
self
,
key
,
value
):
def
enforce_length
(
self
,
key
,
value
):
"""Truncate a string according to its column length
"""Truncate a string according to its column length
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment