mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-08 08:33:45 +01:00
Add Language and PackageTranslation models
This commit is contained in:
parent
357348c24e
commit
e138eb9c72
@ -400,6 +400,7 @@ class Package(db.Model):
|
||||
forums = db.Column(db.Integer, nullable=True)
|
||||
video_url = db.Column(db.String(200), nullable=True, default=None)
|
||||
donate_url = db.Column(db.String(200), nullable=True, default=None)
|
||||
translation_url = db.Column(db.String(200), nullable=True)
|
||||
|
||||
@property
|
||||
def donate_url_actual(self):
|
||||
@ -407,6 +408,10 @@ class Package(db.Model):
|
||||
|
||||
enable_game_support_detection = db.Column(db.Boolean, nullable=False, default=True)
|
||||
|
||||
translations = db.relationship("PackageTranslation", back_populates="package",
|
||||
lazy="dynamic", order_by=db.asc("package_translation_language_id"),
|
||||
cascade="all, delete, delete-orphan")
|
||||
|
||||
provides = db.relationship("MetaPackage", secondary=PackageProvides, order_by=db.asc("name"), back_populates="packages")
|
||||
|
||||
dependencies = db.relationship("Dependency", back_populates="depender", lazy="dynamic", foreign_keys=[Dependency.depender_id])
|
||||
@ -808,6 +813,23 @@ class Package(db.Model):
|
||||
return [positive, neutral, negative]
|
||||
|
||||
|
||||
class Language(db.Model):
|
||||
id = db.Column(db.String(10), primary_key=True)
|
||||
title = db.Column(db.String(100), unique=True, nullable=False)
|
||||
|
||||
|
||||
class PackageTranslation(db.Model):
|
||||
package_id = db.Column(db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
package = db.relationship("Package", back_populates="translations", foreign_keys=[package_id])
|
||||
|
||||
language_id = db.Column(db.String(10), db.ForeignKey("language.id"), primary_key=True)
|
||||
language = db.relationship("Language", foreign_keys=[language_id])
|
||||
|
||||
title = db.Column(db.Unicode(100), nullable=True)
|
||||
short_desc = db.Column(db.Unicode(200), nullable=True)
|
||||
desc = db.Column(db.UnicodeText, nullable=True)
|
||||
|
||||
|
||||
class MetaPackage(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(100), unique=True, nullable=False)
|
||||
|
48
migrations/versions/6a0aee983614_.py
Normal file
48
migrations/versions/6a0aee983614_.py
Normal file
@ -0,0 +1,48 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 6a0aee983614
|
||||
Revises: 7828535fe339
|
||||
Create Date: 2024-02-25 15:26:18.708794
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6a0aee983614'
|
||||
down_revision = '7828535fe339'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('language',
|
||||
sa.Column('id', sa.String(length=10), nullable=False),
|
||||
sa.Column('title', sa.String(length=100), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('title')
|
||||
)
|
||||
|
||||
op.create_table('package_translation',
|
||||
sa.Column('package_id', sa.Integer(), nullable=False),
|
||||
sa.Column('language_id', sa.String(length=10), nullable=False),
|
||||
sa.Column('title', sa.Unicode(length=100), nullable=True),
|
||||
sa.Column('short_desc', sa.Unicode(length=200), nullable=True),
|
||||
sa.Column('desc', sa.UnicodeText(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['language_id'], ['language.id'], ),
|
||||
sa.ForeignKeyConstraint(['package_id'], ['package.id'], ),
|
||||
sa.PrimaryKeyConstraint('package_id', 'language_id')
|
||||
)
|
||||
|
||||
with op.batch_alter_table('package', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('translation_url', sa.String(length=200), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('package', schema=None) as batch_op:
|
||||
batch_op.drop_column('translation_url')
|
||||
|
||||
op.drop_table('package_translation')
|
||||
op.drop_table('language')
|
Loading…
Reference in New Issue
Block a user