Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
where
Commits
021ff387
Unverified
Commit
021ff387
authored
Feb 16, 2020
by
Dylan Jones
Browse files
test data
parent
599f0e67
Changes
3
Hide whitespace changes
Inline
Side-by-side
where/alembic/versions/
1ef22e364966_inital_database_models
.py
→
where/alembic/versions/
26f2853e67de_
.py
View file @
021ff387
"""
inital database models
"""
empty message
Revision ID:
1ef22e364966
Revision ID:
26f2853e67de
Revises:
Create Date: 2020-02-16 19:
28:28.9058
39
Create Date: 2020-02-16 19:
33:26.2753
39
"""
from
alembic
import
op
...
...
@@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision
=
'
1ef22e364966
'
revision
=
'
26f2853e67de
'
down_revision
=
None
branch_labels
=
None
depends_on
=
None
...
...
@@ -27,6 +27,7 @@ def upgrade():
)
op
.
create_table
(
'field'
,
sa
.
Column
(
'id'
,
sa
.
Integer
(),
autoincrement
=
True
,
nullable
=
False
),
sa
.
Column
(
'slug'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'name'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'type'
,
sa
.
Enum
(
'STRING'
,
'FLOAT'
,
'INTEGER'
,
'BOOLEAN'
,
'RATING'
,
name
=
'fieldtype'
),
nullable
=
False
),
sa
.
Column
(
'category_id'
,
sa
.
Integer
(),
nullable
=
True
),
...
...
where/app.py
View file @
021ff387
...
...
@@ -36,9 +36,34 @@ def test_data():
# coldness
cd
=
sa
.
Field
()
cd
.
name
=
"Coldness"
cd
.
slug
=
"coldness"
cd
.
type
=
FieldType
.
RATING
cd
.
category_id
=
wf
.
id
# filler
fl
=
sa
.
Field
()
fl
.
slug
=
"bottle_filler"
fl
.
name
=
"Has Bottle Filler"
fl
.
type
=
FieldType
.
BOOLEAN
fl
.
category_id
=
wf
.
id
session
.
add
(
cd
)
session
.
add
(
fl
)
session
.
commit
()
# an actual instance!
fn
=
sa
.
Point
()
fn
.
name
=
None
fn
.
category_id
=
wf
.
id
fn
.
parent_id
=
None
fn
.
attributes
=
{
"coldness"
:
{
"num_reviews"
:
32
,
"average_rating"
:
0.5
},
"bottle_filler"
:
{
"value"
:
True
}
}
session
.
add
(
fn
)
session
.
commit
()
if
__name__
==
'__main__'
:
...
...
where/sa.py
View file @
021ff387
...
...
@@ -77,6 +77,7 @@ class Field(Base):
"""
__tablename__
=
'field'
slug
=
Column
(
String
,
nullable
=
False
)
name
=
Column
(
String
,
nullable
=
False
)
type
=
Column
(
Enum
(
FieldType
),
nullable
=
False
)
...
...
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