fix: fix
Build and Push Docker Image / build-and-push (push) Has been skipped
Details
Build and Push Docker Image / build-and-push (push) Has been skipped
Details
This commit is contained in:
parent
bafca0ed19
commit
905f4da2d9
|
|
@ -53,6 +53,21 @@ class DatabaseSettings(BaseSettings):
|
|||
validation_alias="DATABASE__AZURIOM_SCHEMA",
|
||||
description="Azuriom database schema name",
|
||||
)
|
||||
luckperms_schema: str = Field(
|
||||
default="hubmc",
|
||||
validation_alias="DATABASE__LUCKPERMS_SCHEMA",
|
||||
description="LuckPerms tables schema",
|
||||
)
|
||||
hub_schema: str = Field(
|
||||
default="hubmc",
|
||||
validation_alias="DATABASE__HUB_SCHEMA",
|
||||
description="Hub tables schema (cooldowns, homes, warps, etc.)",
|
||||
)
|
||||
users_schema: str = Field(
|
||||
default="public",
|
||||
validation_alias="DATABASE__USERS_SCHEMA",
|
||||
description="Users table schema",
|
||||
)
|
||||
pool_size: int = Field(
|
||||
default=10,
|
||||
validation_alias="DATABASE__POOL_SIZE",
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@ from sqlalchemy import (Column, DateTime, ForeignKey, Integer, String,
|
|||
UniqueConstraint)
|
||||
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schemas at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
_LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema
|
||||
|
||||
|
||||
class Cooldown(Base):
|
||||
"""Cooldown model."""
|
||||
|
|
@ -15,6 +20,7 @@ class Cooldown(Base):
|
|||
UniqueConstraint(
|
||||
"player_uuid", "cooldown_type", name="idx_hub_cooldowns_player_type"
|
||||
),
|
||||
{"schema": _HUB_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(
|
||||
|
|
@ -22,11 +28,11 @@ class Cooldown(Base):
|
|||
)
|
||||
player_uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="CASCADE"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
cooldown_type = Column(String(50), nullable=False)
|
||||
expires_at = Column(DateTime(timezone=True), nullable=False, index=True)
|
||||
cooldown_seconds = Column(Integer, nullable=False)
|
||||
data = Column(JSONB)
|
||||
cooldown_metadata = Column("metadata", JSONB)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@ from sqlalchemy import (REAL, Boolean, Column, Float, ForeignKey, String, Text,
|
|||
UniqueConstraint)
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schemas at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
_LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema
|
||||
|
||||
|
||||
class Home(Base):
|
||||
"""Home model."""
|
||||
|
|
@ -13,6 +18,7 @@ class Home(Base):
|
|||
__tablename__ = "hub_homes"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("player_uuid", "name", name="idx_hub_homes_player_name"),
|
||||
{"schema": _HUB_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(
|
||||
|
|
@ -20,7 +26,7 @@ class Home(Base):
|
|||
)
|
||||
player_uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="CASCADE"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,13 +4,18 @@ from sqlalchemy import (BigInteger, Boolean, Column, ForeignKey, Index,
|
|||
Integer, String)
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schema at module load time
|
||||
_LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema
|
||||
|
||||
|
||||
class LuckPermsPlayer(Base):
|
||||
"""LuckPerms Player model."""
|
||||
|
||||
__tablename__ = "luckperms_players"
|
||||
__table_args__ = {"schema": _LUCKPERMS_SCHEMA}
|
||||
|
||||
uuid = Column(String(36), primary_key=True)
|
||||
username = Column(String(16), nullable=False, index=True)
|
||||
|
|
@ -25,6 +30,7 @@ class LuckPermsGroup(Base):
|
|||
"""LuckPerms Group model."""
|
||||
|
||||
__tablename__ = "luckperms_groups"
|
||||
__table_args__ = {"schema": _LUCKPERMS_SCHEMA}
|
||||
|
||||
name = Column(String(36), primary_key=True)
|
||||
|
||||
|
|
@ -41,20 +47,21 @@ class LuckPermsUserPermission(Base):
|
|||
"server",
|
||||
"world",
|
||||
),
|
||||
{"schema": _LUCKPERMS_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="CASCADE"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
permission = Column(String(200), nullable=False)
|
||||
value = Column(Boolean, nullable=False)
|
||||
server = Column(String(36))
|
||||
world = Column(String(64))
|
||||
expiry = Column(BigInteger)
|
||||
contexts = Column(String(200))
|
||||
server = Column(String(36), nullable=False)
|
||||
world = Column(String(64), nullable=False)
|
||||
expiry = Column(BigInteger, nullable=False)
|
||||
contexts = Column(String(200), nullable=False)
|
||||
|
||||
player = relationship("LuckPermsPlayer", back_populates="permissions")
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@ from sqlalchemy import (Boolean, CheckConstraint, Column, DateTime, ForeignKey,
|
|||
Index, String, Text)
|
||||
from sqlalchemy.dialects.postgresql import INET, UUID
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schemas at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
_LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema
|
||||
|
||||
|
||||
class Punishment(Base):
|
||||
"""Punishment model."""
|
||||
|
|
@ -33,6 +38,7 @@ class Punishment(Base):
|
|||
"player_ip",
|
||||
postgresql_where=Column("player_ip").is_not(None),
|
||||
),
|
||||
{"schema": _HUB_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(
|
||||
|
|
@ -40,7 +46,7 @@ class Punishment(Base):
|
|||
)
|
||||
player_uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="CASCADE"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
@ -50,7 +56,7 @@ class Punishment(Base):
|
|||
reason = Column(Text, nullable=False)
|
||||
staff_uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="SET NULL"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="SET NULL"),
|
||||
nullable=False,
|
||||
)
|
||||
staff_name = Column(String(255), nullable=False)
|
||||
|
|
@ -58,7 +64,7 @@ class Punishment(Base):
|
|||
is_active = Column(Boolean, default=True)
|
||||
revoked_at = Column(DateTime(timezone=True))
|
||||
revoked_by = Column(
|
||||
String(36), ForeignKey("luckperms_players.uuid", ondelete="SET NULL")
|
||||
String(36), ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="SET NULL")
|
||||
)
|
||||
revoked_reason = Column(Text)
|
||||
evidence_url = Column(Text)
|
||||
|
|
|
|||
|
|
@ -4,20 +4,26 @@ from sqlalchemy import Column, DateTime, Float, ForeignKey, String, Text
|
|||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schemas at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
_LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema
|
||||
|
||||
|
||||
class TeleportHistory(Base):
|
||||
"""Teleport History model."""
|
||||
|
||||
__tablename__ = "hub_teleport_history"
|
||||
__table_args__ = {"schema": _HUB_SCHEMA}
|
||||
|
||||
id = Column(
|
||||
UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()"
|
||||
)
|
||||
player_uuid = Column(
|
||||
String(36),
|
||||
ForeignKey("luckperms_players.uuid", ondelete="CASCADE"),
|
||||
ForeignKey(f"{_LUCKPERMS_SCHEMA}.luckperms_players.uuid", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,20 +3,28 @@
|
|||
from sqlalchemy import (Boolean, Column, DateTime, ForeignKey, Index, Integer,
|
||||
Numeric, String)
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schema at module load time
|
||||
_USERS_SCHEMA = APP_CONFIG.database.users_schema
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""User model."""
|
||||
|
||||
__tablename__ = "users"
|
||||
__table_args__ = (
|
||||
Index("idx_users_email", "email", unique=True),
|
||||
{"schema": _USERS_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(191), nullable=False)
|
||||
email = Column(String(191), unique=True, nullable=True)
|
||||
email_verified_at = Column(DateTime(timezone=True), nullable=True)
|
||||
password = Column(String(191), nullable=False)
|
||||
role_id = Column(Integer, ForeignKey("roles.id"), nullable=False)
|
||||
role_id = Column(Integer, ForeignKey(f"{_USERS_SCHEMA}.roles.id"), nullable=False)
|
||||
money = Column(Numeric(14, 2), default=0)
|
||||
game_id = Column(String(191), nullable=True)
|
||||
avatar = Column(String, nullable=True) # TEXT поле
|
||||
|
|
@ -31,7 +39,3 @@ class User(Base):
|
|||
updated_at = Column(DateTime(timezone=True), nullable=True)
|
||||
deleted_at = Column(DateTime(timezone=True), nullable=True)
|
||||
password_changed_at = Column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_users_email", "email", unique=True),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@
|
|||
from sqlalchemy import REAL, Boolean, Column, Float, Index, String, Text
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schema at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
|
||||
|
||||
class Warp(Base):
|
||||
"""Warp model."""
|
||||
|
|
@ -15,6 +19,7 @@ class Warp(Base):
|
|||
Index(
|
||||
"idx_hub_warps_public", "is_public", postgresql_where=Column("is_public")
|
||||
),
|
||||
{"schema": _HUB_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@
|
|||
from sqlalchemy import Boolean, Column, DateTime, Index, String
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
from hubgw.core.config import APP_CONFIG
|
||||
from hubgw.models.base import Base
|
||||
|
||||
# Get schema at module load time
|
||||
_HUB_SCHEMA = APP_CONFIG.database.hub_schema
|
||||
|
||||
|
||||
class WhitelistEntry(Base):
|
||||
"""Whitelist entry model."""
|
||||
|
|
@ -21,6 +25,7 @@ class WhitelistEntry(Base):
|
|||
"expires_at",
|
||||
postgresql_where=Column("expires_at").is_not(None),
|
||||
),
|
||||
{"schema": _HUB_SCHEMA},
|
||||
)
|
||||
|
||||
id = Column(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class CooldownsRepository:
|
|||
cooldown_type=request.cooldown_type,
|
||||
expires_at=request.expires_at,
|
||||
cooldown_seconds=request.cooldown_seconds,
|
||||
data=request.data,
|
||||
cooldown_metadata=request.metadata,
|
||||
)
|
||||
self.session.add(cooldown)
|
||||
await self.session.commit()
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ class CooldownBase(BaseModel):
|
|||
"""Base cooldown schema."""
|
||||
|
||||
cooldown_type: str
|
||||
expires_at: datetime
|
||||
cooldown_seconds: int
|
||||
data: Optional[dict] = None
|
||||
metadata: Optional[dict] = None
|
||||
|
||||
|
||||
class CooldownCreate(CooldownBase):
|
||||
"""Cooldown creation schema."""
|
||||
|
||||
player_uuid: str
|
||||
expires_at: Optional[datetime] = None
|
||||
|
||||
|
||||
class Cooldown(CooldownBase, BaseSchema):
|
||||
|
|
@ -44,6 +44,7 @@ class Cooldown(CooldownBase, BaseSchema):
|
|||
|
||||
id: UUID
|
||||
player_uuid: str
|
||||
expires_at: datetime
|
||||
|
||||
|
||||
class CooldownQuery(PaginationParams):
|
||||
|
|
|
|||
|
|
@ -36,4 +36,10 @@ class CooldownsService:
|
|||
|
||||
async def create_cooldown(self, request: CooldownCreate) -> None:
|
||||
"""Create new cooldown."""
|
||||
if request.expires_at is None:
|
||||
from datetime import timedelta
|
||||
|
||||
request.expires_at = datetime.now(timezone.utc) + timedelta(
|
||||
seconds=request.cooldown_seconds
|
||||
)
|
||||
await self.repo.create(request)
|
||||
|
|
|
|||
Loading…
Reference in New Issue