Skip to content

Commit

Permalink
Update the data model for the datawarehouse to make it easier to export
Browse files Browse the repository at this point in the history
  • Loading branch information
danpalmer committed Jan 16, 2018
1 parent 725f6f1 commit 2e91adc
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions routemaster/db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,45 +105,44 @@
'state_machines',
metadata,

Column('name', String, primary_key=True),
Column('updated', DateTime),
Column('id', Integer, primary_key=True, autoincrement=True),
Column('name', String),
Column('updated', DateTime(timezone=True)),
NullableColumn('deleted', DateTime(timezone=True)),
)


"""Represents a state in a state machine."""
states = Table(
'states',
metadata,
Column('name', String, primary_key=True),

Column('id', Integer, primary_key=True, autoincrement=True),
Column('name', String),
Column(
'state_machine',
String,
ForeignKey('state_machines.name'),
primary_key=True,
'state_machine_id',
Integer,
ForeignKey('state_machines.id'),
),

# `deprecated = True` represents a state that is no longer accessible.
Column('deprecated', Boolean, default=False),
NullableColumn('exit_condition', String),
NullableColumn('webhook', String),

Column('updated', DateTime),
Column('updated', DateTime(timezone=True)),
NullableColumn('deleted', DateTime(timezone=True)),
)


"""Represents an edge between states in a state machine."""
edges = Table(
'edges',
metadata,
Column('state_machine', String, primary_key=True),
Column('from_state', String, primary_key=True),
Column('to_state', String, primary_key=True),
Column('deprecated', Boolean, default=False),
Column('updated', DateTime),
ForeignKeyConstraint(
columns=('state_machine', 'from_state'),
refcolumns=(states.c.state_machine, states.c.name),
),
ForeignKeyConstraint(
columns=('state_machine', 'to_state'),
refcolumns=(states.c.state_machine, states.c.name),
),
Column('id', Integer, primary_key=True, autoincrement=True),

Column('state_machine_id', ForeignKey('states.id')),
Column('from_state_id', ForeignKey('states.id')),
Column('to_state_id', ForeignKey('states.id')),

Column('updated', DateTime(timezone=True)),
NullableColumn('deleted', DateTime(timezone=True)),
)

0 comments on commit 2e91adc

Please sign in to comment.