Commit 9baabe1c authored by Zachary Seguin's avatar Zachary Seguin

Database updates

parent 588530c7
......@@ -22,6 +22,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
from __future__ import unicode_literals
from flask.ext.script import Manager, prompt_bool
from . import db
......
......@@ -34,7 +34,7 @@ class AlertCode(db.Model):
alert_id = db.Column(db.Integer, db.ForeignKey('alerts.id', onupdate='cascade', ondelete='cascade'), primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
code = db.Column(db.String(500), nullable=False)
code = db.Column(db.Unicode(500), nullable=False)
alert = db.relationship('Alert',
foreign_keys=[alert_id],
......@@ -45,30 +45,30 @@ class AlertReference(db.Model):
alert_id = db.Column(db.Integer, db.ForeignKey('alerts.id', onupdate='cascade', ondelete='cascade'), primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
sender = db.Column(db.String(500))
identifier = db.Column(db.String(500))
sender = db.Column(db.Unicode(500))
identifier = db.Column(db.Unicode(500))
sent = db.Column(UTCDateTime(timezone=True))
raw = db.Column(db.String(1000))
raw = db.Column(db.Unicode(1000))
class Alert(db.Model):
__tablename__ = 'alerts'
__table_args__ = ( db.UniqueConstraint('identifier', 'sender', 'sent'), { } )
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
identifier = db.Column(db.String(500))
sender = db.Column(db.String(500))
identifier = db.Column(db.Unicode(500))
sender = db.Column(db.Unicode(500))
sent = db.Column(UTCDateTime(timezone=True))
status = db.Column(db.Enum('Actual', 'Excercise', 'System', 'Test', 'Draft', name="statuses"))
msg_type = db.Column(db.Enum('Alert', 'Update', 'Cancel', 'Ack', 'Error', name="msg_types"))
source = db.Column(db.String(500))
source = db.Column(db.Unicode(500))
scope = db.Column(db.Enum('Public', 'Restricted', 'Private', name="scopes"))
restriction = db.Column(db.String(500))
addresses = db.Column(db.String(500))
restriction = db.Column(db.Unicode(500))
addresses = db.Column(db.Unicode(500))
codes = association_proxy('alert_codes', 'code',
creator=lambda v:
AlertCode(code=v))
references = db.relationship('AlertReference', order_by='AlertReference.id', collection_class=ordering_list('id'), backref='alert')
incidents = db.Column(db.String(500))
incidents = db.Column(db.Unicode(500))
infos = db.relationship('Info', order_by='Info.id', collection_class=ordering_list('id', count_from=1), backref='alert')
processed = db.Column(UTCDateTime(timezone=True))
......
......@@ -41,7 +41,7 @@ class AreaPolygon(db.Model):
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
area_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
polygon = db.Column(db.Text)
polygon = db.Column(db.UnicodeText)
area = db.relationship('Area',
foreign_keys=[alert_id,info_id,area_id],
......@@ -60,7 +60,7 @@ class AreaCircle(db.Model):
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
area_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
circle = db.Column(db.Text)
circle = db.Column(db.UnicodeText)
area = db.relationship('Area',
foreign_keys=[alert_id,info_id,area_id],
......@@ -78,8 +78,8 @@ class AreaGeocode(db.Model):
alert_id = db.Column(db.Integer, primary_key=True)
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
area_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
name = db.Column(db.String(500), primary_key=True)
value = db.Column(db.String(500))
name = db.Column(db.Unicode(500), primary_key=True)
value = db.Column(db.Unicode(500))
area = db.relationship('Area',
foreign_keys=[alert_id,info_id,area_id],
......@@ -98,7 +98,7 @@ class Area(db.Model):
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
description = db.Column(db.String(500)) # areaDesc
description = db.Column(db.Unicode(500)) # areaDesc
polygons = association_proxy('area_polygons', 'polygon',
creator=lambda v:
......
......@@ -80,8 +80,8 @@ class InfoEventCode(db.Model):
alert_id = db.Column(db.Integer, primary_key=True)
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
name = db.Column(db.String(500), primary_key=True)
value = db.Column(db.String(500))
name = db.Column(db.Unicode(500), primary_key=True)
value = db.Column(db.Unicode(500))
info = db.relationship('Info',
foreign_keys=[alert_id,info_id],
......@@ -98,8 +98,8 @@ class InfoParameter(db.Model):
alert_id = db.Column(db.Integer, primary_key=True)
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
name = db.Column(db.String(500), primary_key=True)
value = db.Column(db.String(500))
name = db.Column(db.Unicode(500), primary_key=True)
value = db.Column(db.Unicode(500))
info = db.relationship('Info',
foreign_keys=[alert_id,info_id],
......@@ -110,30 +110,30 @@ class Info(db.Model):
alert_id = db.Column(db.Integer, db.ForeignKey("alerts.id", onupdate='cascade', ondelete='cascade'), primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
language = db.Column(db.String(500))
language = db.Column(db.Unicode(500))
categories = association_proxy('info_categories', 'category',
creator=lambda v:
InfoCategory(category=v))
event = db.Column(db.String(500))
event = db.Column(db.Unicode(500))
response_types = association_proxy('info_response_types', 'response_type',
creator=lambda v:
InfoResponseType(response_type=v))
urgency = db.Column(db.Enum('Immediate', 'Expected', 'Future', 'Past', 'Unknown', name="urgencies"))
severity = db.Column(db.Enum('Extreme', 'Severe', 'Moderate', 'Minor', 'Unknown', name="severities"))
certainty = db.Column(db.Enum('Observed', 'Likely', 'Possible', 'Unlikely', 'Unknown', name="certainties"))
audience = db.Column(db.String(500))
audience = db.Column(db.Unicode(500))
event_codes = association_proxy('info_event_codes', 'value',
creator=lambda k, v:
InfoEventCode(name=k, value=v))
effective = db.Column(UTCDateTime(timezone=True))
onset = db.Column(UTCDateTime(timezone=True))
expires = db.Column(UTCDateTime(timezone=True))
sender_name = db.Column(db.String(500))
headline = db.Column(db.String(500))
description = db.Column(db.Text)
instruction = db.Column(db.Text)
web = db.Column(db.String(500))
contact = db.Column(db.String(500))
sender_name = db.Column(db.Unicode(500))
headline = db.Column(db.Unicode(500))
description = db.Column(db.UnicodeText)
instruction = db.Column(db.UnicodeText)
web = db.Column(db.Unicode(500))
contact = db.Column(db.Unicode(500))
parameters = association_proxy('info_parameters', 'value',
creator=lambda k, v:
......
......@@ -27,8 +27,8 @@ from . import db
class Mapping(db.Model):
__tablename__ = 'mappings'
type = db.Column(db.String(20), primary_key=True)
value = db.Column(db.String(100), primary_key=True)
type = db.Column(db.Unicode(20), primary_key=True)
value = db.Column(db.Unicode(100), primary_key=True)
language = db.Column(db.Enum('en-CA', 'fr-CA', name="languages"), primary_key=True)
display_value = db.Column(db.String(200))
display_value = db.Column(db.Unicode(200))
label_class = db.Column(db.Enum('alert', 'warning', 'info', 'success', 'secondary', name="label_classes"), server_default='secondary')
......@@ -37,9 +37,9 @@ class Resource(db.Model):
info_id = db.Column(db.Integer, autoincrement=False, primary_key=True)
id = db.Column(db.Integer, autoincrement=False, primary_key=True)
description = db.Column(db.String(500)) # resourceDesc
mime_type = db.Column(db.String(500))
description = db.Column(db.Unicode(500)) # resourceDesc
mime_type = db.Column(db.Unicode(500))
size = db.Column(db.Integer)
uri = db.Column(db.String(500))
deref_uri = db.Column(db.Text)
digest = db.Column(db.String(500))
uri = db.Column(db.Unicode(500))
deref_uri = db.Column(db.UnicodeText)
digest = db.Column(db.Unicode(500))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment