Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop record states #27

Merged
merged 3 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions routemaster/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from routemaster.config import ConfigError, load_config
from routemaster.server import server
from routemaster.validation import ValidationError, validate_config
from routemaster.record_states import record_state_machines
from routemaster.gunicorn_application import GunicornWSGIApplication

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -92,8 +91,6 @@ def serve(ctx, bind, debug): # pragma: no cover
if debug:
server.config['DEBUG'] = True

record_state_machines(app, app.config.state_machines.values())

cron_thread = CronThread(app)
cron_thread.start()

Expand Down
12 changes: 1 addition & 11 deletions routemaster/db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
"""Public Database interface."""

from routemaster.db.model import (
edges,
labels,
states,
history,
metadata,
state_machines,
)
from routemaster.db.model import labels, history, metadata
from routemaster.db.initialisation import initialise_db

__all__ = (
'edges',
'labels',
'states',
'history',
'metadata',
'state_machines',
'initialise_db',
)
55 changes: 0 additions & 55 deletions routemaster/db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Integer,
DateTime,
MetaData,
ForeignKey,
FetchedValue,
ForeignKeyConstraint,
func,
Expand Down Expand Up @@ -93,57 +92,3 @@
# Null indicates being deleted from a state machine
NullableColumn('new_state', String),
)


"""
Represents a state machine.

We serialise versions of the configuration into the database so that the
structure of the state machines can be exported to a data warehouse.
"""
state_machines = Table(
'state_machines',
metadata,

Column('name', String, primary_key=True),
Column('updated', DateTime),
)


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

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

Column('updated', DateTime),
)


"""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),
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""
drop data warehouse models for now

Revision ID: 9871e5c166b4
Revises: 3eb4f3b419c6
"""
import sqlalchemy as sa

from alembic import op

from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '9871e5c166b4'
down_revision = '3eb4f3b419c6'
branch_labels = None
depends_on = None


def upgrade():
op.drop_table('edges')
op.drop_table('state_machines')
op.drop_table('states')


def downgrade():
op.create_table(
'states',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column(
'state_machine',
sa.VARCHAR(),
autoincrement=False,
nullable=False,
),
sa.Column(
'deprecated',
sa.BOOLEAN(),
server_default=sa.text('false'),
autoincrement=False,
nullable=False,
),
sa.Column(
'updated',
postgresql.TIMESTAMP(),
server_default=sa.text('now()'),
autoincrement=False,
nullable=False,
),
sa.ForeignKeyConstraint(
['state_machine'],
['state_machines.name'],
name='states_state_machine_fkey',
),
sa.PrimaryKeyConstraint('name', 'state_machine', name='states_pkey'),
postgresql_ignore_search_path=False,
)
op.create_table(
'state_machines',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column(
'updated',
postgresql.TIMESTAMP(),
server_default=sa.text('now()'),
autoincrement=False,
nullable=False,
),
sa.PrimaryKeyConstraint('name', name='state_machines_pkey'),
postgresql_ignore_search_path=False,
)
op.create_table(
'edges',
sa.Column(
'state_machine',
sa.VARCHAR(),
autoincrement=False,
nullable=False,
),
sa.Column(
'from_state',
sa.VARCHAR(),
autoincrement=False,
nullable=False,
),
sa.Column(
'to_state',
sa.VARCHAR(),
autoincrement=False,
nullable=False,
),
sa.Column(
'deprecated',
sa.BOOLEAN(),
autoincrement=False,
nullable=False,
),
sa.Column(
'updated',
postgresql.TIMESTAMP(),
autoincrement=False,
nullable=False,
),
sa.ForeignKeyConstraint(
['state_machine', 'from_state'],
['states.state_machine', 'states.name'],
name='edges_state_machine_fkey',
),
sa.ForeignKeyConstraint(
['state_machine', 'to_state'],
['states.state_machine', 'states.name'],
name='edges_state_machine_fkey1',
),
sa.PrimaryKeyConstraint(
'state_machine',
'from_state',
'to_state',
name='edges_pkey',
),
)
7 changes: 0 additions & 7 deletions routemaster/record_states/__init__.py

This file was deleted.

63 changes: 0 additions & 63 deletions routemaster/record_states/api.py

This file was deleted.

Loading