# Path: gogdb/legacy/database.py
# NAMING_CONVENTION = {
#     "ix": 'ix_%(column_0_label)s',
#     "uq": "uq_%(table_name)s_%(column_0_name)s",
#     "ck": "ck_%(table_name)s_%(constraint_name)s",
#     "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
#     "pk": "pk_%(table_name)s"
# }
# 
# Path: gogdb/legacy/model/common.py
# def get_systems_list(self, prefix):
#     systems = []
#     for system_name in ["windows", "mac", "linux"]:
#         if getattr(self, prefix + system_name) is None:
#             return None
#         elif getattr(self, prefix + system_name):
#             systems.append(system_name)
#     return systems
# 
# def set_systems_list(self, prefix, systems):
#     for system_name in ["windows", "mac", "linux"]:
#         if system_name in systems:
#             setattr(self, prefix + system_name, True)
#         else:
#             setattr(self, prefix + system_name, False)


import sqlalchemy as sql
from sqlalchemy import orm
from sqlalchemy import Column
from gogdb.legacy.database import Base
from gogdb.legacy.model.common import get_systems_list, set_systems_list
    developer = orm.relationship("Company", foreign_keys=[developer_slug])
    publisher = orm.relationship("Company", foreign_keys=[publisher_slug])

    dlcs = orm.relationship(
        "Product", backref=orm.backref("base_product", remote_side=[id]))
    languages = orm.relationship(
        "Language", back_populates="product", cascade="all, delete-orphan")
    features = orm.relationship(
        "Feature", back_populates="product", cascade="all, delete-orphan")
    genres = orm.relationship(
        "Genre", back_populates="product", cascade="all, delete-orphan")
    screenshots = orm.relationship(
        "Screenshot", back_populates="product", cascade="all, delete-orphan")
    videos = orm.relationship(
        "Video", back_populates="product", cascade="all, delete-orphan")
    downloads = orm.relationship(
        "Download", back_populates="product", cascade="all, delete-orphan",
        order_by="Download.type, desc(Download.os), Download.slug")
    builds = orm.relationship(
        "Build", back_populates="product", cascade="all, delete-orphan",
        order_by="desc(Build.date_published)")
    pricehistory = orm.relationship(
        "PriceRecord", back_populates="product", cascade="all, delete-orphan",
        order_by="PriceRecord.date")
    changes = orm.relationship(
        "ChangeRecord", back_populates="product", cascade="all, delete-orphan",
        order_by="desc(ChangeRecord.id)")

    cs_systems = property(
        lambda self: get_systems_list(self, "cs_"),

# Path: gogdb/legacy/database.py
# NAMING_CONVENTION = {
#     "ix": 'ix_%(column_0_label)s',
#     "uq": "uq_%(table_name)s_%(column_0_name)s",
#     "ck": "ck_%(table_name)s_%(constraint_name)s",
#     "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
#     "pk": "pk_%(table_name)s"
# }
# 
# Path: gogdb/legacy/model/common.py
# def get_systems_list(self, prefix):
#     systems = []
#     for system_name in ["windows", "mac", "linux"]:
#         if getattr(self, prefix + system_name) is None:
#             return None
#         elif getattr(self, prefix + system_name):
#             systems.append(system_name)
#     return systems
# 
# def set_systems_list(self, prefix, systems):
#     for system_name in ["windows", "mac", "linux"]:
#         if system_name in systems:
#             setattr(self, prefix + system_name, True)
#         else:
#             setattr(self, prefix + system_name, False)


# Path: gogdb/legacy/model/product.py
import sqlalchemy as sql
from sqlalchemy import orm
from sqlalchemy import Column
from gogdb.legacy.database import Base
from gogdb.legacy.model.common import get_systems_list, set_systems_list

    developer = orm.relationship("Company", foreign_keys=[developer_slug])
    publisher = orm.relationship("Company", foreign_keys=[publisher_slug])

    dlcs = orm.relationship(
        "Product", backref=orm.backref("base_product", remote_side=[id]))
    languages = orm.relationship(
        "Language", back_populates="product", cascade="all, delete-orphan")
    features = orm.relationship(
        "Feature", back_populates="product", cascade="all, delete-orphan")
    genres = orm.relationship(
        "Genre", back_populates="product", cascade="all, delete-orphan")
    screenshots = orm.relationship(
        "Screenshot", back_populates="product", cascade="all, delete-orphan")
    videos = orm.relationship(
        "Video", back_populates="product", cascade="all, delete-orphan")
    downloads = orm.relationship(
        "Download", back_populates="product", cascade="all, delete-orphan",
        order_by="Download.type, desc(Download.os), Download.slug")
    builds = orm.relationship(
        "Build", back_populates="product", cascade="all, delete-orphan",
        order_by="desc(Build.date_published)")
    pricehistory = orm.relationship(
        "PriceRecord", back_populates="product", cascade="all, delete-orphan",
        order_by="PriceRecord.date")
    changes = orm.relationship(
        "ChangeRecord", back_populates="product", cascade="all, delete-orphan",
        order_by="desc(ChangeRecord.id)")

    cs_systems = property(
        lambda self: get_systems_list(self, "cs_"),

        lambda self, v: set_systems_list(self, "cs_", v)