mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-08-26 05:44:19 -05:00
add billing timestamps
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""billing_add_timestamps
|
||||
|
||||
Revision ID: d478fe5b757f
|
||||
Revises: 63f1fc2e334c
|
||||
Create Date: 2026-07-10 16:36:08.502358
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd478fe5b757f'
|
||||
down_revision = '63f1fc2e334c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('machine_billing_charge', sa.Column('ins_datetime', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('machine_billing_credit', sa.Column('ins_datetime', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('machine_billing_credit', sa.Column('upd_datetime', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('machine_billing_playcount', sa.Column('ins_datetime', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('machine_billing_playcount', sa.Column('upd_datetime', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('machine_billing_playcount', 'upd_datetime')
|
||||
op.drop_column('machine_billing_playcount', 'ins_datetime ')
|
||||
op.drop_column('machine_billing_credit', 'upd_datetime')
|
||||
op.drop_column('machine_billing_credit', 'ins_datetime ')
|
||||
op.drop_column('machine_billing_charge', 'ins_datetime ')
|
||||
# ### end Alembic commands ###
|
||||
@@ -7,7 +7,7 @@ from sqlalchemy.dialects.mysql import insert
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.sql.schema import ForeignKey, PrimaryKeyConstraint
|
||||
from sqlalchemy.types import JSON, Boolean, Integer, String, BIGINT, INTEGER, CHAR, FLOAT, VARCHAR
|
||||
from sqlalchemy.types import JSON, Boolean, Integer, String, BIGINT, INTEGER, CHAR, FLOAT, VARCHAR, TIMESTAMP
|
||||
|
||||
from core.data.schema.base import BaseData, metadata
|
||||
|
||||
@@ -99,6 +99,7 @@ billing_charge: Table = Table(
|
||||
Column("product_count", INTEGER, nullable=False),
|
||||
Column("func_type", INTEGER, nullable=False),
|
||||
Column("player_number", INTEGER, nullable=False),
|
||||
Column("ins_datetime", TIMESTAMP, nullable=False, server_default=func.now()),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@@ -130,6 +131,8 @@ billing_credit: Table = Table(
|
||||
Column("coin_count_slot5", INTEGER, nullable=False),
|
||||
Column("coin_count_slot6", INTEGER, nullable=False),
|
||||
Column("coin_count_slot7", INTEGER, nullable=False),
|
||||
Column("ins_datetime", TIMESTAMP, nullable=False, server_default=func.now()),
|
||||
Column("upd_datetime", TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now()),
|
||||
UniqueConstraint("machine", "game_id", name="machine_billing_credit_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
@@ -148,6 +151,8 @@ billing_playct: Table = Table(
|
||||
Column("year", INTEGER, nullable=False),
|
||||
Column("month", INTEGER, nullable=False),
|
||||
Column("playct", BIGINT, nullable=False, server_default="1"),
|
||||
Column("ins_datetime", TIMESTAMP, nullable=False, server_default=func.now()),
|
||||
Column("upd_datetime", TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now()),
|
||||
UniqueConstraint("machine", "game_id", "year", "month", name="machine_billing_playcount_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
@@ -494,6 +499,7 @@ class ArcadeData(BaseData):
|
||||
coin_count_slot5=coin_count_slot5,
|
||||
coin_count_slot6=coin_count_slot6,
|
||||
coin_count_slot7=coin_count_slot7,
|
||||
upd_datetime=datetime.now()
|
||||
)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
@@ -519,7 +525,10 @@ class ArcadeData(BaseData):
|
||||
playct=playct
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(playct=billing_playct.c.playct + playct)
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
playct=billing_playct.c.playct + playct,
|
||||
upd_datetime=datetime.now()
|
||||
)
|
||||
result = await self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
|
||||
Reference in New Issue
Block a user