Move all inventory table models to their respective module

This commit is contained in:
Ben 2019-06-07 00:40:32 +01:00
parent d1d2b004c6
commit 5249ce02a5
10 changed files with 166 additions and 170 deletions

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinIgloo, PenguinLocation, PenguinFurniture, PenguinFlooring
class Flooring(db.Model):
@ -69,6 +68,43 @@ class Location(db.Model):
patched = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinIgloo(db.Model):
__tablename__ = 'penguin_igloo'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
igloo_id = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class PenguinLocation(db.Model):
__tablename__ = 'penguin_location'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
location_id = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class PenguinFurniture(db.Model):
__tablename__ = 'penguin_furniture'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
furniture_id = db.Column(db.ForeignKey('furniture.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1"))
class PenguinFlooring(db.Model):
__tablename__ = 'penguin_flooring'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
flooring_id = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class IglooCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinItem
class Item(db.Model):
@ -17,6 +16,15 @@ class Item(db.Model):
release_date = db.Column(db.Date, nullable=False, server_default=db.text("now()"))
class PenguinItem(db.Model):
__tablename__ = 'penguin_item'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True, nullable=False)
item_id = db.Column(db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True, nullable=False)
class ItemCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinPostcard
class Postcard(db.Model):
@ -11,12 +10,26 @@ class Postcard(db.Model):
enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinPostcard(db.Model):
__tablename__ = 'penguin_postcard'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_postcard_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False,
index=True)
sender_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), index=True)
postcard_id = db.Column(db.ForeignKey('postcard.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
send_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
details = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying"))
has_read = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PostcardCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):
super().__init__(model=Postcard,
key='id',
inventory_model=PenguinPostcard,
inventory_key='recipient_id',
inventory_value='postcard_id',
inventory_key='penguin_id',
inventory_value='id',
inventory_id=inventory_id)

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinCard
class Card(db.Model):
@ -15,10 +14,22 @@ class Card(db.Model):
description = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying"))
class PenguinCard(db.Model):
__tablename__ = 'penguin_card'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False, index=True)
card_id = db.Column(db.ForeignKey('card.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1"))
class CardCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):
super().__init__(model=Card,
key='id',
inventory_key='penguin_id',
inventory_value='card_id',
inventory_model=PenguinCard,
inventory_id=inventory_id)

View File

@ -88,64 +88,6 @@ class ActivationKey(db.Model):
activation_key = db.Column(db.CHAR(255), primary_key=True, nullable=False)
class PuffleQuest(db.Model):
__tablename__ = 'puffle_quest'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
task_id = db.Column(db.SmallInteger, primary_key=True, nullable=False)
completion_date = db.Column(db.DateTime)
item_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
coins_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinIgloo(db.Model):
__tablename__ = 'penguin_igloo'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
igloo_id = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class PenguinItem(db.Model):
__tablename__ = 'penguin_item'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True, nullable=False)
item_id = db.Column(db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True, nullable=False)
class PenguinLocation(db.Model):
__tablename__ = 'penguin_location'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
location_id = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class PenguinStamp(db.Model):
__tablename__ = 'penguin_stamp'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
stamp_id = db.Column(db.ForeignKey('stamp.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
recent = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
class PenguinRedemption(db.Model):
__tablename__ = 'penguin_redemption'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
code_id = db.Column(db.ForeignKey('redemption_code.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False, index=True)
book_id = db.Column(db.ForeignKey('redemption_book.id', ondelete='CASCADE', onupdate='CASCADE'), index=True)
class PenguinMembership(db.Model):
__tablename__ = 'penguin_membership'
@ -155,108 +97,6 @@ class PenguinMembership(db.Model):
expires = db.Column(db.DateTime, primary_key=True, nullable=False)
class PenguinPostcard(db.Model):
__tablename__ = 'penguin_postcard'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_postcard_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False,
index=True)
sender_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), index=True)
postcard_id = db.Column(db.ForeignKey('postcard.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
send_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
details = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying"))
has_read = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinIglooRoom(db.Model):
__tablename__ = 'penguin_igloo_room'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_igloo_room_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
type = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
flooring = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
music = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
location = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
locked = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinLaunchGame(db.Model):
__tablename__ = 'penguin_launch_game'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
level = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("0"))
puffle_os = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
best_time = db.Column(db.SmallInteger, nullable=False, server_default=db.text("600"))
turbo = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinCard(db.Model):
__tablename__ = 'penguin_card'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False, index=True)
card_id = db.Column(db.ForeignKey('card.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1"))
class PenguinFurniture(db.Model):
__tablename__ = 'penguin_furniture'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
furniture_id = db.Column(db.ForeignKey('furniture.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1"))
class PenguinFlooring(db.Model):
__tablename__ = 'penguin_flooring'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
flooring_id = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
class PenguinPuffle(db.Model):
__tablename__ = 'penguin_puffle'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_puffle_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
puffle_id = db.Column(db.ForeignKey('puffle.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
name = db.Column(db.String(16), nullable=False)
adoption_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
food = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
play = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
rest = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
clean = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
walking = db.Column(db.Boolean, server_default=db.text("false"))
hat = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
backyard = db.Column(db.Boolean, server_default=db.text("false"))
has_dug = db.Column(db.Boolean, server_default=db.text("false"))
class PenguinPuffleItem(db.Model):
__tablename__ = 'penguin_puffle_item'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
item_id = db.Column(db.Integer, primary_key=True, nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False)
class PenguinPermission(db.Model):
__tablename__ = 'penguin_permission'
penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True)
permission_id = db.Column(db.ForeignKey(u'permission.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), nullable=False)
class Login(db.Model):
__tablename__ = 'login'

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinPermission
class Permission(db.Model):
@ -10,6 +9,13 @@ class Permission(db.Model):
enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
class PenguinPermission(db.Model):
__tablename__ = 'penguin_permission'
penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True)
permission_id = db.Column(db.ForeignKey(u'permission.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), nullable=False)
class PermissionCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinPuffle, PenguinPuffleItem
class Puffle(db.Model):
@ -60,6 +59,57 @@ class PuffleTreasurePuffleItem(db.Model):
primary_key=True, nullable=False)
class PuffleQuest(db.Model):
__tablename__ = 'puffle_quest'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
task_id = db.Column(db.SmallInteger, primary_key=True, nullable=False)
completion_date = db.Column(db.DateTime)
item_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
coins_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PenguinPuffle(db.Model):
__tablename__ = 'penguin_puffle'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_puffle_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
puffle_id = db.Column(db.ForeignKey('puffle.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
name = db.Column(db.String(16), nullable=False)
adoption_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
food = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
play = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
rest = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
clean = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100"))
walking = db.Column(db.Boolean, server_default=db.text("false"))
hat = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'))
backyard = db.Column(db.Boolean, server_default=db.text("false"))
has_dug = db.Column(db.Boolean, server_default=db.text("false"))
class PenguinPuffleItem(db.Model):
__tablename__ = 'penguin_puffle_item'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
item_id = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
quantity = db.Column(db.SmallInteger, nullable=False)
class PenguinLaunchGame(db.Model):
__tablename__ = 'penguin_launch_game'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
level = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("0"))
puffle_os = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
best_time = db.Column(db.SmallInteger, nullable=False, server_default=db.text("600"))
turbo = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class PuffleCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):
@ -67,7 +117,7 @@ class PuffleCrumbsCollection(BaseCrumbsCollection):
key='id',
inventory_model=PenguinPuffle,
inventory_key='penguin_id',
inventory_value='puffle_id',
inventory_value='id',
inventory_id=inventory_id)

View File

@ -92,3 +92,13 @@ class RedemptionAwardPuffleItem(db.Model):
nullable=False)
puffle_item_id = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'),
primary_key=True, nullable=False)
class PenguinRedemption(db.Model):
__tablename__ = 'penguin_redemption'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
code_id = db.Column(db.ForeignKey('redemption_code.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False, index=True)
book_id = db.Column(db.ForeignKey('redemption_book.id', ondelete='CASCADE', onupdate='CASCADE'), index=True)

View File

@ -47,6 +47,19 @@ class Room(db.Model):
await penguin.send_xt(*data)
class PenguinIglooRoom(db.Model):
__tablename__ = 'penguin_igloo_room'
id = db.Column(db.Integer, primary_key=True,
server_default=db.text("nextval('\"penguin_igloo_room_id_seq\"'::regclass)"))
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
type = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
flooring = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
music = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
location = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
locked = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
class RoomTable(db.Model):
__tablename__ = 'room_table'

View File

@ -1,5 +1,4 @@
from houdini.data import db, BaseCrumbsCollection
from houdini.data.penguin import PenguinStamp
class Stamp(db.Model):
@ -36,6 +35,16 @@ class CoverStamp(db.Model):
depth = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
class PenguinStamp(db.Model):
__tablename__ = 'penguin_stamp'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
stamp_id = db.Column(db.ForeignKey('stamp.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
nullable=False)
recent = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
class StampCrumbsCollection(BaseCrumbsCollection):
def __init__(self, inventory_id=None):