Compare commits
16 Commits
develop
...
diva_handl
Author | SHA1 | Date | |
---|---|---|---|
c2ee09bce0 | |||
dfea392b03 | |||
998aa70929 | |||
8df1325613 | |||
6ff7827918 | |||
a36170f2c3 | |||
48144b53f0 | |||
3b852ea739 | |||
21c9b23617 | |||
3076bdf575 | |||
5be25f89ff | |||
5443d24352 | |||
56927c049f | |||
2b81ba206c | |||
9718e822f3 | |||
b07e3d6a94 |
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1,3 +0,0 @@
|
||||
*.csv binary
|
||||
*.txt binary
|
||||
*.json binary
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -145,7 +145,6 @@ dmypy.json
|
||||
cython_debug/
|
||||
|
||||
.vscode/*
|
||||
.vs/*
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
21
Dockerfile
21
Dockerfile
@ -1,21 +0,0 @@
|
||||
FROM python:3.9.15-slim-bullseye
|
||||
|
||||
RUN apt update && apt install default-libmysqlclient-dev build-essential libtk nodejs npm pkg-config -y
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip3 install -r requirements.txt
|
||||
RUN npm i -g nodemon
|
||||
|
||||
COPY entrypoint.sh entrypoint.sh
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
COPY index.py index.py
|
||||
COPY dbutils.py dbutils.py
|
||||
COPY read.py read.py
|
||||
ADD core core
|
||||
ADD titles titles
|
||||
ADD logs logs
|
||||
ADD cert cert
|
||||
|
||||
ENTRYPOINT [ "/app/entrypoint.sh" ]
|
13
LICENSE.txt
13
LICENSE.txt
@ -1,13 +0,0 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
257
changelog.md
257
changelog.md
@ -1,263 +1,6 @@
|
||||
# Changelog
|
||||
Documenting updates to ARTEMiS, to be updated every time the master branch is pushed to.
|
||||
|
||||
## 20250803
|
||||
+ CHUNITHM VERSE support added
|
||||
|
||||
## 20250327
|
||||
+ O.N.G.E.K.I. bright MEMORY Act.3 support added
|
||||
+ CardMaker support updated
|
||||
|
||||
## 20240811
|
||||
### System
|
||||
+ Change backend from Twisted to Starlette
|
||||
+ Implement async handlers
|
||||
+ Reboot times for multiple games have been fixed (thanks zaphkito!)
|
||||
|
||||
### Frontend
|
||||
+ Edit button changed to View on the user page, and is where you can edit the card memo
|
||||
+ Add card now works as it should
|
||||
+ Add event log viewer in the `sys` page for sysadmins
|
||||
+ Add pages for Pokken, SAO, and maimai
|
||||
|
||||
### AimeDB
|
||||
+ Now rejects all-zero access codes
|
||||
+ Stores card IDm (for AmusementIC) and MiFare ID (for old aime/banapass)
|
||||
+ ...unless that MiFare ID is 0x01020304 (the default for segatools)
|
||||
|
||||
### maimai
|
||||
+ Add support for BUDDiES
|
||||
+ Rivals and Favorite Music support
|
||||
|
||||
### Wacca
|
||||
+ Add option to block unregistered serials from accessing the title server
|
||||
|
||||
### DIVA
|
||||
+ Fix for reading modded content (Thanks ThatzOkay!)
|
||||
|
||||
### CHUNITHM
|
||||
+ Save net battle info
|
||||
|
||||
## 20240630
|
||||
### DIVA
|
||||
+ Added configurable festa options'
|
||||
|
||||
## 20240629
|
||||
### CHUNITHM
|
||||
+ Add team points
|
||||
|
||||
## 20240628
|
||||
### maimai
|
||||
+ Add present support
|
||||
|
||||
## 20240627
|
||||
### SAO
|
||||
+ Fix ghost items, character and player XP, EX Bonuses, unlocks, and much much more
|
||||
|
||||
## 20240620
|
||||
### CHUNITHM
|
||||
+ CHUNITHM LUMINOUS support
|
||||
|
||||
## 20240616
|
||||
### CHUNITHM
|
||||
+ Support network encryption for Export/International versions
|
||||
|
||||
### DIVA
|
||||
+ Working frontend with name and level strings edit and playlog
|
||||
|
||||
## 20240530
|
||||
### DIVA
|
||||
+ Fix reader for when dificulty is not a int
|
||||
|
||||
## 20240526
|
||||
### DIVA
|
||||
+ Fixed missing awaits causing coroutine error
|
||||
|
||||
## 20240524
|
||||
### DIVA
|
||||
+ Fixed new profile start request causing coroutine error
|
||||
|
||||
## 20240523
|
||||
### DIVA
|
||||
+ Fixed binary handler & render_POST errors
|
||||
|
||||
## 20240408
|
||||
### System
|
||||
+ Modified the game specific documentation
|
||||
|
||||
## 20240407
|
||||
### Maimai
|
||||
+ Support maimai DX International [#118](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/118) (Thanks beerpsi!)
|
||||
+ Fixed the maimai DX reboot time from config [#120](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/120) (Thanks topty!)
|
||||
|
||||
## 20240318
|
||||
### CXB
|
||||
+ Fixing handle_data_shop_list_detail_request for Sunrise S1
|
||||
|
||||
## 20240302
|
||||
### SAO
|
||||
+ Fixing new profile creation with right heroes and start VP
|
||||
+ Fix to the Unanalyzed Log responses returning the wrong rewards
|
||||
+ Documentation revised
|
||||
|
||||
## 20240226
|
||||
### CXB
|
||||
+ Fixing paths for rev.py
|
||||
+ Changed encoding for handle_data_item_list_icon_request
|
||||
|
||||
## 20240202
|
||||
### SAO
|
||||
+ Added reader assets and edited the game specific documentation
|
||||
|
||||
## 20240118
|
||||
### System
|
||||
+ Added game version names to the readme
|
||||
|
||||
## 20240109
|
||||
### System
|
||||
+ Removed `ADD config config` from dockerfile [#83](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/83) (Thanks zaphkito!)
|
||||
|
||||
### Aimedb
|
||||
+ Fixed an error that resulted from trying to scan a banned or locked card
|
||||
|
||||
## 20240108
|
||||
### System
|
||||
+ Change how the underlying system handles URLs
|
||||
+ This can now allow for things like version-specific, or even keychip-specific URLs
|
||||
+ Specific changes to games are noted below
|
||||
+ Fix docker files [#60](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/60) (Thanks Rylie!)
|
||||
+ Fix support for python 3.8 - 3.10
|
||||
|
||||
### Aimedb
|
||||
+ Add support for SegaAuth key in games that support it (for now only Chunithm)
|
||||
+ This is a JWT that is sent to games, by Aimedb, that the games send to their game server, to verify that the access code the game is sending to the server was obtained via aimedb.
|
||||
+ Requires a base64-encoded secret to be set in the `core.yaml`
|
||||
|
||||
### Chunithm
|
||||
+ Fix Air support
|
||||
+ Add saving for userRecentPlayerList
|
||||
+ Add support for SegaAuthKey
|
||||
+ Fix a bug arising if a user set their name to be 'true' or 'false'
|
||||
+ Add support for Sun+ [#78](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/78) (Thanks EmmyHeart!)
|
||||
+ Add `matching` section to `chuni.yaml`
|
||||
+ ~~Change `udpHolePunchUri` and `reflectorUri` to be STUN and TURN servers~~ Reverted
|
||||
+ Imrpove `GetGameSetting` request handling for different versions
|
||||
+ Fix issue where songs would not always return all scores [#92](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/92) (Thanks Kumubou!)
|
||||
|
||||
### maimai DX
|
||||
+ Fix user charges failing to save
|
||||
|
||||
### maimai
|
||||
+ Made it functional
|
||||
|
||||
### CXB
|
||||
+ Improvements to request dispatching
|
||||
+ Add support for non-omnimix music lists
|
||||
|
||||
|
||||
### IDZ
|
||||
+ Fix news urls in accordance with the system change to URLs
|
||||
|
||||
### Initial D THE ARCADE
|
||||
+ Added support for Initial D THE ARCADE S2
|
||||
+ Story mode progress added
|
||||
+ Bunta Challenge/Touhou Project modes added
|
||||
+ Time Trials added
|
||||
+ Leaderboards added, but doesn't refresh sometimes
|
||||
+ Theory of Street mode added (with CPUs)
|
||||
+ Play Stamp/Timetrial events added
|
||||
+ Frontend to download profile added
|
||||
+ Importer to import profiles added
|
||||
|
||||
### ONGEKI
|
||||
+ Now supports HTTPS on a per-version basis
|
||||
+ Merg PR [#61](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/61) (Thanks phantomlan!)
|
||||
+ Add Ranking Event Support
|
||||
+ Add reward list support
|
||||
+ Add version segregation to Event Ranking, Tech Challenge, and Music Ranking
|
||||
+ Now stores ClientTestmode and ClientSetting data
|
||||
+ Fix mission points not adding correctly [#68](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/68) (Thanks phantomlan!)
|
||||
+ Fix tech challenge [#70](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/70) (Thanks phantomlan!)
|
||||
|
||||
### SAO
|
||||
+ Change endpoint in accordance with the system change to URLs
|
||||
+ Update request header class to be more accurate
|
||||
+ Encrypted requests are now supported
|
||||
+ Change to using handler classes instead of raw structs for simplicity
|
||||
|
||||
### Wacca
|
||||
+ Fix a server error causing a seperate error that casued issues
|
||||
+ Add better error printing
|
||||
+ Add better request validation
|
||||
+ Fix HousingStartV2
|
||||
+ Fix Lily's housing/get handler
|
||||
|
||||
## 20231107
|
||||
### CXB
|
||||
+ Hotfix `render_POST` sometimes failing to read the request body on large requests
|
||||
|
||||
## 20231106
|
||||
### CXB
|
||||
+ Hotfix `render_POST` function signature signature
|
||||
+ Hotfix `handle_action_addenergy_request` hard failing if `get_energy` returns None
|
||||
|
||||
## 20231015
|
||||
### maimai DX
|
||||
+ Added support for FESTiVAL PLUS
|
||||
|
||||
### Card Maker
|
||||
+ Added support for maimai DX FESTiVAL PLUS
|
||||
|
||||
## 20230716
|
||||
### General
|
||||
+ Docker files added (#19)
|
||||
+ Added support for threading
|
||||
+ This comes with the caviat that enabling it will not allow you to use Ctrl + C to stop the server.
|
||||
|
||||
### Webui
|
||||
+ Small improvements
|
||||
+ Add card display
|
||||
|
||||
### Allnet
|
||||
+ Billing format validation
|
||||
+ Fix naomitest.html endpoint
|
||||
+ Add event logging for auths and billing
|
||||
+ LoaderStateRecorder endpoint handler added
|
||||
|
||||
### Mucha
|
||||
+ Fixed log level always being "Info"
|
||||
+ Add stub handler for DownloadState
|
||||
|
||||
### Sword Art Online
|
||||
+ Support added
|
||||
|
||||
### Crossbeats
|
||||
+ Added threading to profile loading
|
||||
+ This should cause a noticeable speed-up
|
||||
|
||||
### Card Maker
|
||||
+ DX Passes fixed
|
||||
+ Various improvements
|
||||
|
||||
### Diva
|
||||
+ Added clear status calculation
|
||||
+ Various minor fixes and improvements
|
||||
|
||||
### Maimai
|
||||
+ Added support for memorial photo uploads
|
||||
+ Added support for the following versions
|
||||
+ Festival
|
||||
+ FiNALE
|
||||
+ Various bug fixes and improvements
|
||||
|
||||
### Wacca
|
||||
+ Fixed an error that sometimes occoured when trying to unlock songs (#22)
|
||||
|
||||
### Pokken
|
||||
+ Profile saving added (loading TBA)
|
||||
+ Use external STUN server for matching by default
|
||||
+ Matching still not working
|
||||
|
||||
## 2023042300
|
||||
### Wacca
|
||||
+ Time free now works properly
|
||||
|
180
contributing.md
180
contributing.md
@ -1,182 +1,8 @@
|
||||
# Contributing to ARTEMiS
|
||||
If you would like to contribute to artemis, either by adding features, games, or fixing bugs, you can do so by forking the repo and submitting a pull request [here](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls). This guide assume you're familiar with both git, python, and the libraries that artemis uses.
|
||||
|
||||
This document is a work in progress. If you have any questions or notice any errors, please report it to the discord.
|
||||
If you would like to contribute to artemis, either by adding features, games, or fixing bugs, you can do so by forking the repo and submitting a pull request [here](https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls). Please make sure, if you're submitting a PR for a game or game version, that you're following the n-0/y-1 guidelines, or it will be rejected.
|
||||
|
||||
## Adding games
|
||||
### Step 0
|
||||
+ Follow the "n-1" rule of thumb. PRs for game versions that are currently active in arcades will be deleted. If you're unsure, ask!
|
||||
+ Always PR against the `develop` branch.
|
||||
+ Check to see if somebody else is already PRing the features/games you want to add. If they are, consider contributing to them rather then making an entirely new PR.
|
||||
+ We don't technically have a written code style guide (TODO) but try to keep your code consistant with code that's already there where possible.
|
||||
|
||||
### Step 1 (Setup)
|
||||
1) Fork the gitea repo, clone your fork, and checkout the develop branch.
|
||||
2) Make a new folder in the `titles` folder, name it some recogniseable shorthand for your game (Chunithm becomes chuni, maimai dx is mai2, etc)
|
||||
3) In this new folder, create a file named `__init__.py`. This is the first thing that will load when your title module is loaded by the core system, and it acts as sort of a directory for where everything lives in your module. This file will contain the following required items:
|
||||
+ `index`: must point to a subclass of `BaseServlet` that will handle setup and dispatching of your game.
|
||||
+ `game_codes`: must be a list of 4 letter SEGA game codes as strings.
|
||||
|
||||
It can also contain the following optional fields:
|
||||
+ `database`: points to a subclass of `Data` that contains one or more subclasses of `BaseData` that act as database transaction handlers. Required for the class to store and retrieve data from the database.
|
||||
+ `reader`: points to a subclass of `BaseReader` that handles importing static data from game files into the database.
|
||||
+ `frontend`: points to a subclass of `FE_Base` that handles frontend routes for your game.
|
||||
|
||||
The next step will focus on `index`
|
||||
|
||||
### Step 2 (Index)
|
||||
1) Create another file in your game's folder. By convention, it should be called `index.py`.
|
||||
|
||||
2) Inside `index.py`, add the following code, replacing {Game name here} with the name of your game, without spaces or special characters. Look at other titles for examples.
|
||||
```py
|
||||
from core.title import BaseServlet
|
||||
from core import CoreConfig
|
||||
|
||||
class {Game name here}Servlet(BaseServlet):
|
||||
def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None:
|
||||
pass
|
||||
```
|
||||
3) The `__init__` function should acomplish the following:
|
||||
+ Reading your game's config
|
||||
+ Setting up your games logger
|
||||
+ Instancing your games versions
|
||||
|
||||
It's usually safe to copy and paste the `__init__` functions from other games, just make sure you change everything that needs to be changed!
|
||||
|
||||
4) Go back to the `__init__.py` that you created and add the following:
|
||||
```py
|
||||
from .index import {Game name here}Servlet
|
||||
|
||||
index = {Game name here}Servlet
|
||||
```
|
||||
|
||||
5) Going back to `index.py`, within the Servlet class, define the following functions from `BaseServlet` as needed (see function documentation):
|
||||
+ `is_game_enabled`: Returns true if the game is enabled and should be served, false otherwise. Returns false by default, so override this to allow your game to be served.
|
||||
+ `get_routes`: Returns a list of Starlette routes that your game will serve.
|
||||
+ `get_allnet_info`: Returns a tuple of strings where the first is the allnet uri and the second is the allnet host. The function takes the game ID, version and keychip ID as parameters, so you can send different responses if need be.
|
||||
+ `get_mucha_info`: Only used by games that use Mucha as authentication. Returns a tuple where the first is a bool that is weather or not the game is enabled, the 2nd is a list of game CDs as strings that this servlet should handle, and the 3rd is a list of netID prefixes that each game CD should use. If your game does not use mucha, do not define this function.
|
||||
+ `setup`: Preforms any setup your servlet requires, such as spinning up matching servers. It is run once when the server starts. If you don't need any setup, do not define.
|
||||
|
||||
6) Make sure any functions you specify to handle routes in `get_routes` are defined as async, as follows: `async def handle_thing(self, request: Request) -> Response:` where Response is whatever kind of Response class you'll be returning. Make sure all paths in this function return some subclass of Response, otherwise you'll get an error when serving.
|
||||
|
||||
### Step 3 (Constants)
|
||||
1) In your game's folder, create a file to store static values for your game. By convention, we call this `const.py`
|
||||
|
||||
2) Inside, create a class called `{Game name here}Constants`. Do not define an `__init__` function.
|
||||
|
||||
3) Put constants related to your game here. A good example of something to put here is game codes.
|
||||
```py
|
||||
class {Game name here}Constants:
|
||||
GAME_CODE = "SBXX"
|
||||
CONFIG_NAME = "{game name}.yaml"
|
||||
```
|
||||
|
||||
4) If you choose to put game codes in here, add this to your `__init__.py` file:
|
||||
```py
|
||||
from .const import {Game name here}Constants
|
||||
...
|
||||
game_codes = [{Game name here}Constants.GAME_CODE]
|
||||
```
|
||||
|
||||
### Step 4 (Config)
|
||||
1) Make a file to store your game's config. By convention, it should be called `config.py`
|
||||
|
||||
2) Inside that file, add the following:
|
||||
```py
|
||||
from core.config import CoreConfig
|
||||
|
||||
class {game name}ServerConfig:
|
||||
def __init__(self, parent_config: "{game name}Config") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def enable(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "{game name}", "server", "enable", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
CoreConfig.get_config_field(
|
||||
self.__config, "{game name}", "server", "loglevel", default="info"
|
||||
)
|
||||
)
|
||||
|
||||
class {game name}Config(dict):
|
||||
def __init__(self) -> None:
|
||||
self.server = {game name}ServerConfig(self)
|
||||
```
|
||||
|
||||
3) In the `example_config` folder, create a yaml file for your game. By convention, it should be called `{game folder name}.ymal`. Add the following:
|
||||
```yaml
|
||||
server:
|
||||
enable: True
|
||||
loglevel: "info"
|
||||
```
|
||||
|
||||
4) Add any additional config options that you feel the game needs. Look to other games for config examples.
|
||||
|
||||
5) In `index.py` import your config and instance it in `__init__` with:
|
||||
```py
|
||||
self.game_cfg = {game folder name}Config()
|
||||
if path.exists(f"{cfg_dir}/{game folder name}Constants.CONFIG_NAME}"):
|
||||
self.game_cfg.update(
|
||||
yaml.safe_load(open(f"{cfg_dir}/{game folder name}Constants.CONFIG_NAME}"))
|
||||
)
|
||||
```
|
||||
This will attempt to load the config file you specified in your constants, and if not, go with the defaults specified in `config.py`. This game_cfg object can then be passed down to your handlers when you create them.
|
||||
|
||||
At this stage your game should be loaded by allnet, and serve whatever routes you put in `get_routes`. See the next section about adding versions and handlers.
|
||||
|
||||
### Step 5 (Database)
|
||||
TODO
|
||||
|
||||
### Step 6 (Frontend)
|
||||
TODO
|
||||
|
||||
### Step 7 (Reader)
|
||||
TODO
|
||||
Guide WIP
|
||||
|
||||
## Adding game versions
|
||||
See the above section about code expectations and how to PR.
|
||||
1) In the game's folder, create a python file to contain the version handlers. By convention, the first version is version 0, and is stored in `base.py`. Versions following that increment the version number, and are stored in `{short version name}.py`. See Wacca's folder for an example of how to name versions.
|
||||
|
||||
2) Internal version numbers should be defined in `const.py`. The version should change any time the game gets a major update (i.e. a new version or plus version.)
|
||||
```py
|
||||
# in const.py
|
||||
VERSION_{game name} = 0
|
||||
VERSION_{game name}_PLUS = 1
|
||||
```
|
||||
|
||||
3) Inside `base.py` (or whatever your version is named) add the following:
|
||||
```py
|
||||
class {game name}Base:
|
||||
def __init__(self, cfg: CoreConfig, game_cfg: {game name}Config) -> None:
|
||||
self.game_config = game_cfg
|
||||
self.core_config = cfg
|
||||
self.version = {game name}Constants.VERSION_{game name}
|
||||
self.data = {game name}Data(cfg)
|
||||
# Any other initialization stuff
|
||||
```
|
||||
|
||||
4) Define your handlers. This will vary wildly by game, but best practice is to keep the naming consistant, so that the main dispatch function in `index.py` can use `getattr` to get the handler, rather then having a static list of what endpoint or request type goes to which handler. See Wacca's `index.py` and `base.py` for examples of how to do this.
|
||||
|
||||
5) If your version is not the base version, make sure it inherits from the base version:
|
||||
```py
|
||||
class {game name}Plus({game name}Base):
|
||||
def __init__(self, cfg: CoreConfig, game_cfg: {game name}Config) -> None:
|
||||
super().__init__(cfg, game_cfg)
|
||||
self.version = {game name}Constants.VERSION_{game name}_PLUS
|
||||
```
|
||||
|
||||
6) Back in `index.py` make sure to import your new class, and add it to `__init__`. Some games may opt to just a single list called `self.versions` that contains all the version classes at their internal version's index. Others may simply define them as seperate members. See Wacca for an example of `self.versions`
|
||||
|
||||
7) Add your version to your game's dispatching logic.
|
||||
|
||||
8) Test to make sure your game is being handled properly.
|
||||
|
||||
9) Submit a PR.
|
||||
|
||||
## Adding/improving core services
|
||||
If you intend to submit improvements or additions to core services (allnet, mucha, billing, aimedb, database, etc) please get in touch with a maintainer.
|
||||
Guide WIP
|
@ -1,5 +1,7 @@
|
||||
from core.config import CoreConfig
|
||||
from core.aimedb import AimedbServlette
|
||||
from core.allnet import AllnetServlet
|
||||
from core.aimedb import AimedbFactory
|
||||
from core.title import TitleServlet
|
||||
from core.utils import Utils
|
||||
from core.mucha import MuchaServlet
|
||||
from core.frontend import FrontendServlet
|
||||
|
@ -1,6 +0,0 @@
|
||||
from .base import ADBBaseRequest, ADBBaseResponse, ADBHeader, ADBHeaderException, PortalRegStatus, LogStatus, ADBStatus
|
||||
from .base import CompanyCodes, ReaderFwVer, CMD_CODE_GOODBYE, HEADER_SIZE
|
||||
from .lookup import ADBLookupRequest, ADBLookupResponse, ADBLookupExResponse
|
||||
from .campaign import ADBCampaignClearRequest, ADBCampaignClearResponse, ADBCampaignResponse, ADBOldCampaignRequest, ADBOldCampaignResponse
|
||||
from .felica import ADBFelicaLookupRequest, ADBFelicaLookupResponse, ADBFelicaLookupExRequest, ADBFelicaLookupExResponse
|
||||
from .log import ADBLogExRequest, ADBLogRequest, ADBStatusLogRequest, ADBLogExResponse
|
@ -1,170 +0,0 @@
|
||||
import struct
|
||||
from construct import Struct, Int16ul, Int32ul, PaddedString
|
||||
from enum import Enum
|
||||
import re
|
||||
from typing import Union, Final
|
||||
|
||||
class LogStatus(Enum):
|
||||
NONE = 0
|
||||
START = 1
|
||||
CONTINUE = 2
|
||||
END = 3
|
||||
OTHER = 4
|
||||
|
||||
class PortalRegStatus(Enum):
|
||||
NO_REG = 0
|
||||
PORTAL = 1
|
||||
SEGA_ID = 2
|
||||
|
||||
class ADBStatus(Enum):
|
||||
UNKNOWN = 0
|
||||
GOOD = 1
|
||||
BAD_AMIE_ID = 2
|
||||
ALREADY_REG = 3
|
||||
BAN_SYS_USER = 4
|
||||
BAN_SYS = 5
|
||||
BAN_USER = 6
|
||||
BAN_GEN = 7
|
||||
LOCK_SYS_USER = 8
|
||||
LOCK_SYS = 9
|
||||
LOCK_USER = 10
|
||||
|
||||
class CompanyCodes(Enum):
|
||||
NONE = 0
|
||||
SEGA = 1
|
||||
BAMCO = 2
|
||||
KONAMI = 3
|
||||
TAITO = 4
|
||||
|
||||
class ReaderFwVer(Enum): # Newer readers use a singly byte value
|
||||
NONE = 0
|
||||
TN32_10 = 1
|
||||
TN32_12 = 2
|
||||
OTHER = 9
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self == self.TN32_10:
|
||||
return "TN32MSEC003S F/W Ver1.0"
|
||||
elif self == self.TN32_12:
|
||||
return "TN32MSEC003S F/W Ver1.2"
|
||||
elif self == self.NONE:
|
||||
return "Not Specified"
|
||||
elif self == self.OTHER:
|
||||
return "Unknown/Other"
|
||||
else:
|
||||
raise ValueError(f"Bad ReaderFwVer value {self.value}")
|
||||
|
||||
@classmethod
|
||||
def from_byte(self, byte: bytes) -> Union["ReaderFwVer", int]:
|
||||
try:
|
||||
i = int.from_bytes(byte, 'little')
|
||||
try:
|
||||
return ReaderFwVer(i)
|
||||
except ValueError:
|
||||
return i
|
||||
except TypeError:
|
||||
return 0
|
||||
|
||||
class ADBHeaderException(Exception):
|
||||
pass
|
||||
|
||||
HEADER_SIZE: Final[int] = 0x20
|
||||
CMD_CODE_GOODBYE: Final[int] = 0x66
|
||||
|
||||
# everything is LE
|
||||
class ADBHeader:
|
||||
def __init__(self, magic: int, protocol_ver: int, cmd: int, length: int, status: int, game_id: Union[str, bytes], store_id: int, keychip_id: Union[str, bytes]) -> None:
|
||||
self.magic = magic # u16
|
||||
self.protocol_ver = protocol_ver # u16
|
||||
self.cmd = cmd # u16
|
||||
self.length = length # u16
|
||||
try:
|
||||
self.status = ADBStatus(status) # u16
|
||||
except ValueError as e:
|
||||
raise ADBHeaderException(f"Status is incorrect! {e}")
|
||||
self.game_id = game_id # 4 char + \x00
|
||||
self.store_id = store_id # u32
|
||||
self.keychip_id = keychip_id# 11 char + \x00
|
||||
|
||||
if type(self.game_id) == bytes:
|
||||
self.game_id = self.game_id.decode()
|
||||
|
||||
if type(self.keychip_id) == bytes:
|
||||
self.keychip_id = self.keychip_id.decode()
|
||||
|
||||
self.game_id = self.game_id.replace("\0", "")
|
||||
self.keychip_id = self.keychip_id.replace("\0", "")
|
||||
if self.cmd != CMD_CODE_GOODBYE: # Games for some reason send no data with goodbye
|
||||
self.validate()
|
||||
|
||||
@classmethod
|
||||
def from_data(cls, data: bytes) -> "ADBHeader":
|
||||
magic, protocol_ver, cmd, length, status, game_id, store_id, keychip_id = struct.unpack_from("<5H6sI12s", data)
|
||||
head = cls(magic, protocol_ver, cmd, length, status, game_id, store_id, keychip_id)
|
||||
|
||||
if head.length > len(data):
|
||||
raise ADBHeaderException(f"Length is incorrect! Expect {head.length}, got {len(data)}")
|
||||
|
||||
return head
|
||||
|
||||
def validate(self) -> bool:
|
||||
if self.magic != 0xa13e:
|
||||
raise ADBHeaderException(f"Magic {self.magic} != 0xa13e")
|
||||
|
||||
if self.protocol_ver < 0x1000:
|
||||
raise ADBHeaderException(f"Protocol version {hex(self.protocol_ver)} is invalid!")
|
||||
|
||||
if re.fullmatch(r"^S[0-9A-Z]{3}[P]?$", self.game_id) is None:
|
||||
raise ADBHeaderException(f"Game ID {self.game_id} is invalid!")
|
||||
|
||||
if self.store_id == 0:
|
||||
raise ADBHeaderException(f"Store ID cannot be 0!")
|
||||
|
||||
if re.fullmatch(r"^A[0-9]{2}[A-Z][0-9]{2}[A-HJ-NP-Z][0-9]{4}$", self.keychip_id) is None:
|
||||
raise ADBHeaderException(f"Keychip ID {self.keychip_id} is invalid!")
|
||||
|
||||
return True
|
||||
|
||||
def make(self) -> bytes:
|
||||
resp_struct = Struct(
|
||||
"magic" / Int16ul,
|
||||
"unknown" / Int16ul,
|
||||
"response_code" / Int16ul,
|
||||
"length" / Int16ul,
|
||||
"status" / Int16ul,
|
||||
"game_id" / PaddedString(6, 'utf_8'),
|
||||
"store_id" / Int32ul,
|
||||
"keychip_id" / PaddedString(12, 'utf_8'),
|
||||
)
|
||||
|
||||
return resp_struct.build(dict(
|
||||
magic=self.magic,
|
||||
unknown=self.protocol_ver,
|
||||
response_code=self.cmd,
|
||||
length=self.length,
|
||||
status=self.status.value,
|
||||
game_id = self.game_id,
|
||||
store_id = self.store_id,
|
||||
keychip_id = self.keychip_id,
|
||||
))
|
||||
|
||||
class ADBBaseRequest:
|
||||
def __init__(self, data: bytes) -> None:
|
||||
self.head = ADBHeader.from_data(data)
|
||||
|
||||
class ADBBaseResponse:
|
||||
def __init__(self, code: int = 0, length: int = 0x20, status: int = 1, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", protocol_ver: int = 0x3087) -> None:
|
||||
self.head = ADBHeader(0xa13e, protocol_ver, code, length, status, game_id, store_id, keychip_id)
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader, cmd: int, length: int = 0x20, status: int = 1) -> "ADBBaseResponse":
|
||||
return cls(cmd, length, status, req.game_id, req.store_id, req.keychip_id, req.protocol_ver)
|
||||
|
||||
def append_padding(self, data: bytes):
|
||||
"""Appends 0s to the end of the data until it's at the correct size"""
|
||||
padding_size = self.head.length - len(data)
|
||||
data += bytes(padding_size)
|
||||
return data
|
||||
|
||||
def make(self) -> bytes:
|
||||
return self.head.make()
|
@ -1,132 +0,0 @@
|
||||
from construct import Struct, Int16ul, Padding, Bytes, Int32ul, Int32sl
|
||||
|
||||
from .base import *
|
||||
|
||||
class Campaign:
|
||||
def __init__(self) -> None:
|
||||
self.id = 0
|
||||
self.name = ""
|
||||
self.announce_date = 0
|
||||
self.start_date = 0
|
||||
self.end_date = 0
|
||||
self.distrib_start_date = 0
|
||||
self.distrib_end_date = 0
|
||||
|
||||
def make(self) -> bytes:
|
||||
name_padding = bytes(128 - len(self.name))
|
||||
return Struct(
|
||||
"id" / Int32ul,
|
||||
"name" / Bytes(128),
|
||||
"announce_date" / Int32ul,
|
||||
"start_date" / Int32ul,
|
||||
"end_date" / Int32ul,
|
||||
"distrib_start_date" / Int32ul,
|
||||
"distrib_end_date" / Int32ul,
|
||||
Padding(8),
|
||||
).build(dict(
|
||||
id = self.id,
|
||||
name = self.name.encode() + name_padding,
|
||||
announce_date = self.announce_date,
|
||||
start_date = self.start_date,
|
||||
end_date = self.end_date,
|
||||
distrib_start_date = self.distrib_start_date,
|
||||
distrib_end_date = self.distrib_end_date,
|
||||
))
|
||||
|
||||
class CampaignClear:
|
||||
def __init__(self) -> None:
|
||||
self.id = 0
|
||||
self.entry_flag = 0
|
||||
self.clear_flag = 0
|
||||
|
||||
def make(self) -> bytes:
|
||||
return Struct(
|
||||
"id" / Int32ul,
|
||||
"entry_flag" / Int32ul,
|
||||
"clear_flag" / Int32ul,
|
||||
Padding(4),
|
||||
).build(dict(
|
||||
id = self.id,
|
||||
entry_flag = self.entry_flag,
|
||||
clear_flag = self.clear_flag,
|
||||
))
|
||||
|
||||
class ADBCampaignResponse(ADBBaseResponse):
|
||||
def __init__(self, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x0C, length: int = 0x200, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.campaigns = [Campaign(), Campaign(), Campaign()]
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader) -> "ADBCampaignResponse":
|
||||
c = cls(req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
body = b""
|
||||
|
||||
for c in self.campaigns:
|
||||
body += c.make()
|
||||
|
||||
self.head.length = HEADER_SIZE + len(body)
|
||||
return self.head.make() + body
|
||||
|
||||
class ADBOldCampaignRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.campaign_id = struct.unpack_from("<I", data, 0x20)
|
||||
|
||||
class ADBOldCampaignResponse(ADBBaseResponse):
|
||||
def __init__(self, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x0C, length: int = 0x30, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.info0 = 0
|
||||
self.info1 = 0
|
||||
self.info2 = 0
|
||||
self.info3 = 0
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader) -> "ADBCampaignResponse":
|
||||
c = cls(req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
resp_struct = Struct(
|
||||
"info0" / Int32sl,
|
||||
"info1" / Int32sl,
|
||||
"info2" / Int32sl,
|
||||
"info3" / Int32sl,
|
||||
).build(
|
||||
info0 = self.info0,
|
||||
info1 = self.info1,
|
||||
info2 = self.info2,
|
||||
info3 = self.info3,
|
||||
)
|
||||
|
||||
self.head.length = HEADER_SIZE + len(resp_struct)
|
||||
return self.head.make() + resp_struct
|
||||
|
||||
class ADBCampaignClearRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.aime_id = struct.unpack_from("<i", data, 0x20)
|
||||
|
||||
class ADBCampaignClearResponse(ADBBaseResponse):
|
||||
def __init__(self, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x0E, length: int = 0x50, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.campaign_clear_status = [CampaignClear(), CampaignClear(), CampaignClear()]
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader) -> "ADBCampaignResponse":
|
||||
c = cls(req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
body = b""
|
||||
|
||||
for c in self.campaign_clear_status:
|
||||
body += c.make()
|
||||
|
||||
self.head.length = HEADER_SIZE + len(body)
|
||||
return self.head.make() + body
|
@ -1,86 +0,0 @@
|
||||
from construct import Struct, Int32sl, Padding, Int8ub, Int16sl
|
||||
from typing import Union
|
||||
from .base import *
|
||||
|
||||
class ADBFelicaLookupRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
idm, pmm = struct.unpack_from(">QQ", data, 0x20)
|
||||
self.idm = hex(idm)[2:].upper()
|
||||
self.pmm = hex(pmm)[2:].upper()
|
||||
|
||||
class ADBFelicaLookupResponse(ADBBaseResponse):
|
||||
def __init__(self, access_code: str = None, idx: int = 0, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x03, length: int = 0x30, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.access_code = access_code if access_code is not None else "00000000000000000000"
|
||||
self.idx = idx
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader, access_code: str = None, idx: int = 0) -> "ADBFelicaLookupResponse":
|
||||
c = cls(access_code, idx, req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
resp_struct = Struct(
|
||||
"felica_idx" / Int32ul,
|
||||
"access_code" / Int8ub[10],
|
||||
Padding(2)
|
||||
).build(dict(
|
||||
felica_idx = self.idx,
|
||||
access_code = bytes.fromhex(self.access_code)
|
||||
))
|
||||
|
||||
self.head.length = HEADER_SIZE + len(resp_struct)
|
||||
|
||||
return self.head.make() + resp_struct
|
||||
|
||||
class ADBFelicaLookupExRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.random = struct.unpack_from("<16s", data, 0x20)[0]
|
||||
idm, dfc, self.arbitrary = struct.unpack_from(">QH6s", data, 0x30)
|
||||
self.card_key_ver, self.write_ct, self.maca, company, fw_ver, self.dfc = struct.unpack_from("<16s16sQccH", data, 0x40)
|
||||
self.idm = hex(idm)[2:].upper()
|
||||
self.dfc = hex(dfc)[2:].upper()
|
||||
self.company = CompanyCodes(int.from_bytes(company, 'little'))
|
||||
self.fw_ver = ReaderFwVer.from_byte(fw_ver)
|
||||
|
||||
class ADBFelicaLookupExResponse(ADBBaseResponse):
|
||||
def __init__(self, user_id: Union[int, None] = None, access_code: Union[str, None] = None, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x12, length: int = 0x130, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.user_id = user_id if user_id is not None else -1
|
||||
self.access_code = access_code if access_code is not None else "00000000000000000000"
|
||||
self.company = CompanyCodes.SEGA
|
||||
self.portal_status = PortalRegStatus.NO_REG
|
||||
self.auth_key = [0] * 256
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader, user_id: Union[int, None] = None, access_code: Union[str, None] = None) -> "ADBFelicaLookupExResponse":
|
||||
c = cls(user_id, access_code, req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
resp_struct = Struct(
|
||||
"user_id" / Int32sl,
|
||||
"relation1" / Int32sl,
|
||||
"relation2" / Int32sl,
|
||||
"access_code" / Int8ub[10],
|
||||
"portal_status" / Int8ub,
|
||||
"company_code" / Int8ub,
|
||||
Padding(8),
|
||||
"auth_key" / Int8ub[256],
|
||||
).build(dict(
|
||||
user_id = self.user_id,
|
||||
relation1 = -1, # Unsupported
|
||||
relation2 = -1, # Unsupported
|
||||
access_code = bytes.fromhex(self.access_code),
|
||||
portal_status = self.portal_status.value,
|
||||
company_code = self.company.value,
|
||||
auth_key = self.auth_key
|
||||
))
|
||||
|
||||
self.head.length = HEADER_SIZE + len(resp_struct)
|
||||
|
||||
return self.head.make() + resp_struct
|
@ -1,56 +0,0 @@
|
||||
from construct import Struct, Padding, Int8sl
|
||||
from typing import Final, List
|
||||
|
||||
from .base import *
|
||||
NUM_LOGS: Final[int] = 20
|
||||
NUM_LEN_LOG_EX: Final[int] = 48
|
||||
|
||||
class AmLogEx:
|
||||
def __init__(self, data: bytes) -> None:
|
||||
self.aime_id, status, self.user_id, self.credit_ct, self.bet_ct, self.won_ct, self.local_time, \
|
||||
self.tseq, self.place_id = struct.unpack("<IIQiii4xQiI", data)
|
||||
self.status = LogStatus(status)
|
||||
|
||||
class ADBStatusLogRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.aime_id, status = struct.unpack_from("<II", data, 0x20)
|
||||
self.status = LogStatus(status)
|
||||
|
||||
class ADBLogRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.aime_id, status, self.user_id, self.credit_ct, self.bet_ct, self.won_ct = struct.unpack_from("<IIQiii", data, 0x20)
|
||||
self.status = LogStatus(status)
|
||||
|
||||
class ADBLogExRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.logs: List[AmLogEx] = []
|
||||
|
||||
for x in range(NUM_LOGS):
|
||||
self.logs.append(AmLogEx(data[0x20 + (NUM_LEN_LOG_EX * x): 0x50 + (NUM_LEN_LOG_EX * x)]))
|
||||
|
||||
self.num_logs = struct.unpack_from("<I", data, 0x03E0)[0]
|
||||
|
||||
class ADBLogExResponse(ADBBaseResponse):
|
||||
def __init__(self, game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", protocol_ver: int = 12423, code: int = 20, length: int = 64, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id, protocol_ver)
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader) -> "ADBLogExResponse":
|
||||
c = cls(req.game_id, req.store_id, req.keychip_id, req.protocol_ver)
|
||||
return c
|
||||
|
||||
def make(self) -> bytes:
|
||||
resp_struct = Struct(
|
||||
"log_result" / Int8sl[NUM_LOGS],
|
||||
Padding(12)
|
||||
)
|
||||
|
||||
body = resp_struct.build(dict(
|
||||
log_result = [1] * NUM_LOGS
|
||||
))
|
||||
|
||||
self.head.length = HEADER_SIZE + len(body)
|
||||
return self.head.make() + body
|
@ -1,82 +0,0 @@
|
||||
from construct import Struct, Int32sl, Padding, Int8sl
|
||||
from typing import Union
|
||||
|
||||
from .base import *
|
||||
|
||||
class ADBLookupException(Exception):
|
||||
pass
|
||||
|
||||
class ADBLookupRequest(ADBBaseRequest):
|
||||
def __init__(self, data: bytes) -> None:
|
||||
super().__init__(data)
|
||||
self.access_code = data[0x20:0x2A].hex()
|
||||
company_code, fw_version, self.serial_number = struct.unpack_from("<bbI", data, 0x2A)
|
||||
|
||||
try:
|
||||
self.company_code = CompanyCodes(company_code)
|
||||
except ValueError as e:
|
||||
raise ADBLookupException(f"Invalid company code - {e}")
|
||||
|
||||
self.fw_version = ReaderFwVer.from_byte(fw_version)
|
||||
|
||||
class ADBLookupResponse(ADBBaseResponse):
|
||||
def __init__(self, user_id: Union[int, None], game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888", code: int = 0x06, length: int = 0x30, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.user_id = user_id if user_id is not None else -1
|
||||
self.portal_reg = PortalRegStatus.NO_REG
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader, user_id: Union[int, None]) -> "ADBLookupResponse":
|
||||
c = cls(user_id, req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self):
|
||||
resp_struct = Struct(
|
||||
"user_id" / Int32sl,
|
||||
"portal_reg" / Int8sl,
|
||||
Padding(11)
|
||||
)
|
||||
|
||||
body = resp_struct.build(dict(
|
||||
user_id = self.user_id,
|
||||
portal_reg = self.portal_reg.value
|
||||
))
|
||||
|
||||
self.head.length = HEADER_SIZE + len(body)
|
||||
return self.head.make() + body
|
||||
|
||||
class ADBLookupExResponse(ADBBaseResponse):
|
||||
def __init__(self, user_id: Union[int, None], game_id: str = "SXXX", store_id: int = 1, keychip_id: str = "A69E01A8888",
|
||||
code: int = 0x10, length: int = 0x130, status: int = 1) -> None:
|
||||
super().__init__(code, length, status, game_id, store_id, keychip_id)
|
||||
self.user_id = user_id if user_id is not None else -1
|
||||
self.portal_reg = PortalRegStatus.NO_REG
|
||||
self.auth_key = [0] * 256
|
||||
|
||||
@classmethod
|
||||
def from_req(cls, req: ADBHeader, user_id: Union[int, None]) -> "ADBLookupExResponse":
|
||||
c = cls(user_id, req.game_id, req.store_id, req.keychip_id)
|
||||
c.head.protocol_ver = req.protocol_ver
|
||||
return c
|
||||
|
||||
def make(self):
|
||||
resp_struct = Struct(
|
||||
"user_id" / Int32sl,
|
||||
"portal_reg" / Int8sl,
|
||||
Padding(3),
|
||||
"auth_key" / Int8sl[256],
|
||||
"relation1" / Int32sl,
|
||||
"relation2" / Int32sl,
|
||||
)
|
||||
|
||||
body = resp_struct.build(dict(
|
||||
user_id = self.user_id,
|
||||
portal_reg = self.portal_reg.value,
|
||||
auth_key = self.auth_key,
|
||||
relation1 = -1,
|
||||
relation2 = -1
|
||||
))
|
||||
|
||||
self.head.length = HEADER_SIZE + len(body)
|
||||
return self.head.make() + body
|
616
core/aimedb.py
616
core/aimedb.py
@ -1,451 +1,297 @@
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
import logging, coloredlogs
|
||||
from Crypto.Cipher import AES
|
||||
from typing import Dict, Tuple, Callable, Union, Optional
|
||||
import asyncio
|
||||
import struct
|
||||
from typing import Dict, Any
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core.utils import create_sega_auth_key
|
||||
from core.data import Data
|
||||
from .adb_handlers import *
|
||||
|
||||
class AimedbServlette():
|
||||
request_list: Dict[int, Tuple[Callable[[bytes, int], Union[ADBBaseResponse, bytes]], int, str]] = {}
|
||||
def __init__(self, core_cfg: CoreConfig) -> None:
|
||||
self.config = core_cfg
|
||||
self.data = Data(core_cfg)
|
||||
|
||||
class AimedbProtocol(Protocol):
|
||||
AIMEDB_RESPONSE_CODES = {
|
||||
"felica_lookup": 0x03,
|
||||
"lookup": 0x06,
|
||||
"log": 0x0A,
|
||||
"campaign": 0x0C,
|
||||
"touch": 0x0E,
|
||||
"lookup2": 0x10,
|
||||
"felica_lookup2": 0x12,
|
||||
"log2": 0x14,
|
||||
"hello": 0x65,
|
||||
}
|
||||
|
||||
request_list: Dict[int, Any] = {}
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig) -> None:
|
||||
self.logger = logging.getLogger("aimedb")
|
||||
if not hasattr(self.logger, "initted"):
|
||||
log_fmt_str = "[%(asctime)s] Aimedb | %(levelname)s | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
|
||||
fileHandler = TimedRotatingFileHandler(
|
||||
"{0}/{1}.log".format(self.config.server.log_dir, "aimedb"),
|
||||
when="d",
|
||||
backupCount=10,
|
||||
)
|
||||
fileHandler.setFormatter(log_fmt)
|
||||
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(log_fmt)
|
||||
|
||||
self.logger.addHandler(fileHandler)
|
||||
self.logger.addHandler(consoleHandler)
|
||||
|
||||
self.logger.setLevel(self.config.aimedb.loglevel)
|
||||
coloredlogs.install(
|
||||
level=core_cfg.aimedb.loglevel, logger=self.logger, fmt=log_fmt_str
|
||||
)
|
||||
self.logger.initted = True
|
||||
|
||||
if not core_cfg.aimedb.key:
|
||||
self.config = core_cfg
|
||||
self.data = Data(core_cfg)
|
||||
if core_cfg.aimedb.key == "":
|
||||
self.logger.error("!!!KEY NOT SET!!!")
|
||||
exit(1)
|
||||
|
||||
self.register_handler(0x01, 0x03, self.handle_felica_lookup, 'felica_lookup')
|
||||
self.register_handler(0x02, 0x03, self.handle_felica_register, 'felica_register')
|
||||
self.request_list[0x01] = self.handle_felica_lookup
|
||||
self.request_list[0x04] = self.handle_lookup
|
||||
self.request_list[0x05] = self.handle_register
|
||||
self.request_list[0x09] = self.handle_log
|
||||
self.request_list[0x0B] = self.handle_campaign
|
||||
self.request_list[0x0D] = self.handle_touch
|
||||
self.request_list[0x0F] = self.handle_lookup2
|
||||
self.request_list[0x11] = self.handle_felica_lookup2
|
||||
self.request_list[0x13] = self.handle_log2
|
||||
self.request_list[0x64] = self.handle_hello
|
||||
|
||||
self.register_handler(0x04, 0x06, self.handle_lookup, 'lookup')
|
||||
self.register_handler(0x05, 0x06, self.handle_register, 'register')
|
||||
def append_padding(self, data: bytes):
|
||||
"""Appends 0s to the end of the data until it's at the correct size"""
|
||||
length = struct.unpack_from("<H", data, 6)
|
||||
padding_size = length[0] - len(data)
|
||||
data += bytes(padding_size)
|
||||
return data
|
||||
|
||||
self.register_handler(0x07, 0x08, self.handle_status_log, 'status_log')
|
||||
self.register_handler(0x09, 0x0A, self.handle_log, 'aime_log')
|
||||
def connectionMade(self) -> None:
|
||||
self.logger.debug(f"{self.transport.getPeer().host} Connected")
|
||||
|
||||
self.register_handler(0x0B, 0x0C, self.handle_campaign, 'campaign')
|
||||
self.register_handler(0x0D, 0x0E, self.handle_campaign_clear, 'campaign_clear')
|
||||
def connectionLost(self, reason) -> None:
|
||||
self.logger.debug(
|
||||
f"{self.transport.getPeer().host} Disconnected - {reason.value}"
|
||||
)
|
||||
|
||||
self.register_handler(0x0F, 0x10, self.handle_lookup_ex, 'lookup_ex')
|
||||
self.register_handler(0x11, 0x12, self.handle_felica_lookup_ex, 'felica_lookup_ex')
|
||||
|
||||
self.register_handler(0x13, 0x14, self.handle_log_ex, 'aime_log_ex')
|
||||
self.register_handler(0x64, 0x65, self.handle_hello, 'hello')
|
||||
|
||||
def register_handler(self, cmd: int, resp:int, handler: Callable[[bytes, int], Union[ADBBaseResponse, bytes]], name: str) -> None:
|
||||
self.request_list[cmd] = (handler, resp, name)
|
||||
|
||||
def start(self) -> None:
|
||||
self.logger.info(f"Start on port {self.config.aimedb.port}")
|
||||
addr = self.config.aimedb.listen_address if self.config.aimedb.listen_address else self.config.server.listen_address
|
||||
asyncio.create_task(asyncio.start_server(self.dataReceived, addr, self.config.aimedb.port))
|
||||
|
||||
async def dataReceived(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter):
|
||||
self.logger.debug(f"Connection made from {writer.get_extra_info('peername')[0]}")
|
||||
while True:
|
||||
try:
|
||||
data: bytes = await reader.read(4096)
|
||||
if len(data) == 0:
|
||||
self.logger.debug("Connection closed")
|
||||
return
|
||||
await self.process_data(data, reader, writer)
|
||||
await writer.drain()
|
||||
except ConnectionResetError as e:
|
||||
self.logger.debug("Connection reset, disconnecting")
|
||||
return
|
||||
|
||||
async def process_data(self, data: bytes, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> Optional[bytes]:
|
||||
addr = writer.get_extra_info('peername')[0]
|
||||
def dataReceived(self, data: bytes) -> None:
|
||||
cipher = AES.new(self.config.aimedb.key.encode(), AES.MODE_ECB)
|
||||
|
||||
try:
|
||||
decrypted = cipher.decrypt(data)
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to decrypt {data.hex()} because {e}")
|
||||
return
|
||||
except:
|
||||
self.logger.error(f"Failed to decrypt {data.hex()}")
|
||||
return None
|
||||
|
||||
self.logger.debug(f"{addr} wrote {decrypted.hex()}")
|
||||
self.logger.debug(f"{self.transport.getPeer().host} wrote {decrypted.hex()}")
|
||||
|
||||
if not decrypted[1] == 0xA1 and not decrypted[0] == 0x3E:
|
||||
self.logger.error(f"Bad magic")
|
||||
return None
|
||||
|
||||
req_code = decrypted[4]
|
||||
|
||||
if req_code == 0x66:
|
||||
self.logger.info(f"goodbye from {self.transport.getPeer().host}")
|
||||
self.transport.loseConnection()
|
||||
return
|
||||
|
||||
try:
|
||||
head = ADBHeader.from_data(decrypted)
|
||||
|
||||
except ADBHeaderException as e:
|
||||
self.logger.error(f"Error parsing ADB header: {e}")
|
||||
try:
|
||||
encrypted = cipher.encrypt(ADBBaseResponse().make())
|
||||
writer.write(encrypted)
|
||||
await writer.drain()
|
||||
return
|
||||
resp = self.request_list[req_code](decrypted)
|
||||
encrypted = cipher.encrypt(resp)
|
||||
self.logger.debug(f"Response {resp.hex()}")
|
||||
self.transport.write(encrypted)
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to encrypt default response because {e}")
|
||||
|
||||
return
|
||||
except KeyError:
|
||||
self.logger.error(f"Unknown command code {hex(req_code)}")
|
||||
return None
|
||||
|
||||
if head.keychip_id == "ABCD1234567" or head.store_id == 0xfff0:
|
||||
self.logger.warning(f"Request from uninitialized AMLib: {vars(head)}")
|
||||
except ValueError as e:
|
||||
self.logger.error(f"Failed to encrypt {resp.hex()} because {e}")
|
||||
return None
|
||||
|
||||
if head.cmd == 0x66:
|
||||
self.logger.info("Goodbye")
|
||||
writer.close()
|
||||
return
|
||||
|
||||
handler, resp_code, name = self.request_list.get(head.cmd, (self.handle_default, None, 'default'))
|
||||
|
||||
if resp_code is None:
|
||||
self.logger.warning(f"No handler for cmd {hex(head.cmd)}")
|
||||
|
||||
elif resp_code > 0:
|
||||
self.logger.info(f"{name} from {head.keychip_id} ({head.game_id}) @ {addr}")
|
||||
|
||||
resp = await handler(decrypted, resp_code)
|
||||
|
||||
if type(resp) == ADBBaseResponse or issubclass(type(resp), ADBBaseResponse):
|
||||
resp_bytes = resp.make()
|
||||
|
||||
elif type(resp) == bytes:
|
||||
resp_bytes = resp
|
||||
|
||||
elif resp is None: # Nothing to send, probably a goodbye
|
||||
self.logger.warning(f"None return by handler for {name}")
|
||||
return
|
||||
|
||||
else:
|
||||
self.logger.error(f"Unsupported type returned by ADB handler for {name}: {type(resp)}")
|
||||
raise TypeError(f"Unsupported type returned by ADB handler for {name}: {type(resp)}")
|
||||
|
||||
try:
|
||||
encrypted = cipher.encrypt(resp_bytes)
|
||||
self.logger.debug(f"Response {resp_bytes.hex()}")
|
||||
writer.write(encrypted)
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to encrypt {resp_bytes.hex()} because {e}")
|
||||
|
||||
async def handle_default(self, data: bytes, resp_code: int, length: int = 0x20) -> ADBBaseResponse:
|
||||
req = ADBHeader.from_data(data)
|
||||
return ADBBaseResponse(resp_code, length, 1, req.game_id, req.store_id, req.keychip_id, req.protocol_ver)
|
||||
|
||||
async def handle_hello(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||
return await self.handle_default(data, resp_code)
|
||||
|
||||
async def handle_campaign(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||
h = ADBHeader.from_data(data)
|
||||
if h.protocol_ver >= 0x3030:
|
||||
req = h
|
||||
resp = ADBCampaignResponse.from_req(req)
|
||||
|
||||
else:
|
||||
req = ADBOldCampaignRequest(data)
|
||||
|
||||
self.logger.info(f"Legacy campaign request for campaign {req.campaign_id} (protocol version {hex(h.protocol_ver)})")
|
||||
resp = ADBOldCampaignResponse.from_req(req.head)
|
||||
|
||||
# We don't currently support campaigns
|
||||
return resp
|
||||
|
||||
async def handle_lookup(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||
req = ADBLookupRequest(data)
|
||||
if req.access_code == "00000000000000000000":
|
||||
self.logger.warning(f"All-zero access code from {req.head.keychip_id}")
|
||||
ret = ADBLookupResponse.from_req(req.head, -1)
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
|
||||
user_id = await self.data.card.get_user_id_from_card(req.access_code)
|
||||
is_banned = await self.data.card.get_card_banned(req.access_code)
|
||||
is_locked = await self.data.card.get_card_locked(req.access_code)
|
||||
|
||||
ret = ADBLookupResponse.from_req(req.head, user_id)
|
||||
if is_banned and is_locked:
|
||||
ret.head.status = ADBStatus.BAN_SYS_USER
|
||||
elif is_banned:
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
elif is_locked:
|
||||
ret.head.status = ADBStatus.LOCK_USER
|
||||
|
||||
self.logger.info(
|
||||
f"access_code {req.access_code} -> user_id {ret.user_id}"
|
||||
def handle_campaign(self, data: bytes) -> bytes:
|
||||
self.logger.info(f"campaign from {self.transport.getPeer().host}")
|
||||
ret = struct.pack(
|
||||
"<5H",
|
||||
0xA13E,
|
||||
0x3087,
|
||||
self.AIMEDB_RESPONSE_CODES["campaign"],
|
||||
0x0200,
|
||||
0x0001,
|
||||
)
|
||||
|
||||
if user_id and user_id > 0:
|
||||
await self.data.card.update_card_last_login(req.access_code)
|
||||
if (req.access_code.startswith("010") or req.access_code.startswith("3")) and req.serial_number != 0x04030201: # Default segatools sn
|
||||
await self.data.card.set_chip_id_by_access_code(req.access_code, req.serial_number)
|
||||
self.logger.info(f"Attempt to set chip id to {req.serial_number:08X} for access code {req.access_code}")
|
||||
return ret
|
||||
return self.append_padding(ret)
|
||||
|
||||
async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||
req = ADBLookupRequest(data)
|
||||
if req.access_code == "00000000000000000000":
|
||||
self.logger.warning(f"All-zero access code from {req.head.keychip_id}")
|
||||
ret = ADBLookupExResponse.from_req(req.head, -1)
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
|
||||
user_id = await self.data.card.get_user_id_from_card(req.access_code)
|
||||
|
||||
is_banned = await self.data.card.get_card_banned(req.access_code)
|
||||
is_locked = await self.data.card.get_card_locked(req.access_code)
|
||||
|
||||
ret = ADBLookupExResponse.from_req(req.head, user_id)
|
||||
if is_banned and is_locked:
|
||||
ret.head.status = ADBStatus.BAN_SYS_USER
|
||||
elif is_banned:
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
elif is_locked:
|
||||
ret.head.status = ADBStatus.LOCK_USER
|
||||
|
||||
self.logger.info(
|
||||
f"access_code {req.access_code} -> user_id {ret.user_id}"
|
||||
def handle_hello(self, data: bytes) -> bytes:
|
||||
self.logger.info(f"hello from {self.transport.getPeer().host}")
|
||||
ret = struct.pack(
|
||||
"<5H", 0xA13E, 0x3087, self.AIMEDB_RESPONSE_CODES["hello"], 0x0020, 0x0001
|
||||
)
|
||||
return self.append_padding(ret)
|
||||
|
||||
if user_id and user_id > 0 and self.config.aimedb.id_secret:
|
||||
auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, req.head.keychip_id, self.config.aimedb.id_secret, self.config.aimedb.id_lifetime_seconds)
|
||||
if auth_key is not None:
|
||||
auth_key_extra_len = 256 - len(auth_key)
|
||||
auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len)
|
||||
self.logger.debug(f"Generated auth token {auth_key}")
|
||||
ret.auth_key = auth_key_full
|
||||
|
||||
if user_id and user_id > 0:
|
||||
await self.data.card.update_card_last_login(req.access_code)
|
||||
return ret
|
||||
|
||||
async def handle_felica_lookup(self, data: bytes, resp_code: int) -> bytes:
|
||||
"""
|
||||
On official, the IDm is used as a key to look up the stored access code in a large
|
||||
database. We do not have access to that database so we have to make due with what we got.
|
||||
Interestingly, namco games are able to read S_PAD0 and send the server the correct access
|
||||
code, but aimedb doesn't. Until somebody either enters the correct code manually, or scans
|
||||
on a game that reads it correctly from the card, this will have to do. It's the same conversion
|
||||
used on the big boy networks.
|
||||
"""
|
||||
req = ADBFelicaLookupRequest(data)
|
||||
idm = req.idm.zfill(16)
|
||||
if idm == "0000000000000000":
|
||||
self.logger.warning(f"All-zero IDm from {req.head.keychip_id}")
|
||||
ret = ADBFelicaLookupResponse.from_req(req.head, "00000000000000000000")
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
|
||||
card = await self.data.card.get_card_by_idm(idm)
|
||||
if not card:
|
||||
ac = self.data.card.to_access_code(idm)
|
||||
test = await self.data.card.get_card_by_access_code(ac)
|
||||
if test:
|
||||
await self.data.card.set_idm_by_access_code(ac, idm)
|
||||
|
||||
else:
|
||||
ac = card['access_code']
|
||||
|
||||
self.logger.info(
|
||||
f"idm {idm} pmm {req.pmm.zfill(16)} -> access_code {ac}"
|
||||
)
|
||||
return ADBFelicaLookupResponse.from_req(req.head, ac)
|
||||
|
||||
async def handle_felica_register(self, data: bytes, resp_code: int) -> bytes:
|
||||
"""
|
||||
Used to register felica moble access codes. Will never be used on our network
|
||||
because we don't implement felica_lookup properly.
|
||||
"""
|
||||
req = ADBFelicaLookupRequest(data)
|
||||
idm = req.idm.zfill(16)
|
||||
|
||||
if idm == "0000000000000000":
|
||||
self.logger.warning(f"All-zero IDm from {req.head.keychip_id}")
|
||||
ret = ADBFelicaLookupResponse.from_req(req.head, "00000000000000000000")
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
|
||||
ac = self.data.card.to_access_code(req.idm)
|
||||
|
||||
if self.config.server.allow_user_registration:
|
||||
user_id = await self.data.user.create_user()
|
||||
|
||||
if user_id is None:
|
||||
self.logger.error("Failed to register user!")
|
||||
user_id = -1
|
||||
|
||||
else:
|
||||
card_id = await self.data.card.create_card(user_id, ac)
|
||||
|
||||
if card_id is None:
|
||||
self.logger.error("Failed to register card!")
|
||||
user_id = -1
|
||||
|
||||
self.logger.info(
|
||||
f"Register access code {ac} (IDm: {req.idm} PMm: {req.pmm}) -> user_id {user_id}"
|
||||
)
|
||||
|
||||
else:
|
||||
self.logger.info(
|
||||
f"Registration blocked!: access code {ac} (IDm: {req.idm} PMm: {req.pmm})"
|
||||
)
|
||||
|
||||
if user_id > 0:
|
||||
await self.data.card.update_card_last_login(ac)
|
||||
return ADBFelicaLookupResponse.from_req(req.head, ac)
|
||||
|
||||
async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes:
|
||||
req = ADBFelicaLookupExRequest(data)
|
||||
user_id = None
|
||||
idm = req.idm.zfill(16)
|
||||
|
||||
if idm == "0000000000000000":
|
||||
self.logger.warning(f"All-zero IDm from {req.head.keychip_id}")
|
||||
ret = ADBFelicaLookupExResponse.from_req(req.head, -1, "00000000000000000000")
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
|
||||
card = await self.data.card.get_card_by_idm(idm)
|
||||
if not card:
|
||||
access_code = self.data.card.to_access_code(idm)
|
||||
card = await self.data.card.get_card_by_access_code(access_code)
|
||||
if card:
|
||||
user_id = card['user']
|
||||
await self.data.card.set_idm_by_access_code(access_code, idm)
|
||||
|
||||
else:
|
||||
user_id = card['user']
|
||||
access_code = card['access_code']
|
||||
def handle_lookup(self, data: bytes) -> bytes:
|
||||
luid = data[0x20:0x2A].hex()
|
||||
user_id = self.data.card.get_user_id_from_card(access_code=luid)
|
||||
|
||||
if user_id is None:
|
||||
user_id = -1
|
||||
|
||||
self.logger.info(
|
||||
f"idm {idm} dfc {req.dfc} -> access_code {access_code} user_id {user_id}"
|
||||
f"lookup from {self.transport.getPeer().host}: luid {luid} -> user_id {user_id}"
|
||||
)
|
||||
|
||||
resp = ADBFelicaLookupExResponse.from_req(req.head, user_id, access_code)
|
||||
|
||||
if user_id > 0:
|
||||
if card['is_banned'] and card['is_locked']:
|
||||
resp.head.status = ADBStatus.BAN_SYS_USER
|
||||
elif card['is_banned']:
|
||||
resp.head.status = ADBStatus.BAN_SYS
|
||||
elif card['is_locked']:
|
||||
resp.head.status = ADBStatus.LOCK_USER
|
||||
ret = struct.pack(
|
||||
"<5H", 0xA13E, 0x3087, self.AIMEDB_RESPONSE_CODES["lookup"], 0x0130, 0x0001
|
||||
)
|
||||
ret += bytes(0x20 - len(ret))
|
||||
|
||||
if user_id and user_id > 0 and self.config.aimedb.id_secret:
|
||||
auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, req.head.keychip_id, self.config.aimedb.id_secret, self.config.aimedb.id_lifetime_seconds)
|
||||
if auth_key is not None:
|
||||
auth_key_extra_len = 256 - len(auth_key)
|
||||
auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len)
|
||||
self.logger.debug(f"Generated auth token {auth_key}")
|
||||
resp.auth_key = auth_key_full
|
||||
|
||||
if user_id and user_id > 0:
|
||||
await self.data.card.update_card_last_login(access_code)
|
||||
return resp
|
||||
if user_id is None:
|
||||
ret += struct.pack("<iH", -1, 0)
|
||||
else:
|
||||
ret += struct.pack("<l", user_id)
|
||||
return self.append_padding(ret)
|
||||
|
||||
async def handle_campaign_clear(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||
req = ADBCampaignClearRequest(data)
|
||||
def handle_lookup2(self, data: bytes) -> bytes:
|
||||
self.logger.info(f"lookup2")
|
||||
|
||||
resp = ADBCampaignClearResponse.from_req(req.head)
|
||||
ret = bytearray(self.handle_lookup(data))
|
||||
ret[4] = self.AIMEDB_RESPONSE_CODES["lookup2"]
|
||||
|
||||
# We don't support campaign stuff
|
||||
return resp
|
||||
return bytes(ret)
|
||||
|
||||
async def handle_register(self, data: bytes, resp_code: int) -> bytes:
|
||||
req = ADBLookupRequest(data)
|
||||
user_id = -1
|
||||
|
||||
if req.access_code == "00000000000000000000":
|
||||
self.logger.warning(f"All-zero access code from {req.head.keychip_id}")
|
||||
ret = ADBLookupResponse.from_req(req.head, -1)
|
||||
ret.head.status = ADBStatus.BAN_SYS
|
||||
return ret
|
||||
def handle_felica_lookup(self, data: bytes) -> bytes:
|
||||
idm = data[0x20:0x28].hex()
|
||||
pmm = data[0x28:0x30].hex()
|
||||
access_code = self.data.card.to_access_code(idm)
|
||||
self.logger.info(
|
||||
f"felica_lookup from {self.transport.getPeer().host}: idm {idm} pmm {pmm} -> access_code {access_code}"
|
||||
)
|
||||
|
||||
ret = struct.pack(
|
||||
"<5H",
|
||||
0xA13E,
|
||||
0x3087,
|
||||
self.AIMEDB_RESPONSE_CODES["felica_lookup"],
|
||||
0x0030,
|
||||
0x0001,
|
||||
)
|
||||
ret += bytes(26)
|
||||
ret += bytes.fromhex(access_code)
|
||||
|
||||
return self.append_padding(ret)
|
||||
|
||||
def handle_felica_lookup2(self, data: bytes) -> bytes:
|
||||
idm = data[0x30:0x38].hex()
|
||||
pmm = data[0x38:0x40].hex()
|
||||
access_code = self.data.card.to_access_code(idm)
|
||||
user_id = self.data.card.get_user_id_from_card(access_code=access_code)
|
||||
|
||||
if user_id is None:
|
||||
user_id = -1
|
||||
|
||||
self.logger.info(
|
||||
f"felica_lookup2 from {self.transport.getPeer().host}: idm {idm} ipm {pmm} -> access_code {access_code} user_id {user_id}"
|
||||
)
|
||||
|
||||
ret = struct.pack(
|
||||
"<5H",
|
||||
0xA13E,
|
||||
0x3087,
|
||||
self.AIMEDB_RESPONSE_CODES["felica_lookup2"],
|
||||
0x0140,
|
||||
0x0001,
|
||||
)
|
||||
ret += bytes(22)
|
||||
ret += struct.pack("<lq", user_id, -1) # first -1 is ext_id, 3rd is access code
|
||||
ret += bytes.fromhex(access_code)
|
||||
ret += struct.pack("<l", 1)
|
||||
|
||||
return self.append_padding(ret)
|
||||
|
||||
def handle_touch(self, data: bytes) -> bytes:
|
||||
self.logger.info(f"touch from {self.transport.getPeer().host}")
|
||||
ret = struct.pack(
|
||||
"<5H", 0xA13E, 0x3087, self.AIMEDB_RESPONSE_CODES["touch"], 0x0050, 0x0001
|
||||
)
|
||||
ret += bytes(5)
|
||||
ret += struct.pack("<3H", 0x6F, 0, 1)
|
||||
|
||||
return self.append_padding(ret)
|
||||
|
||||
def handle_register(self, data: bytes) -> bytes:
|
||||
luid = data[0x20:0x2A].hex()
|
||||
if self.config.server.allow_user_registration:
|
||||
user_id = await self.data.user.create_user()
|
||||
user_id = self.data.user.create_user()
|
||||
|
||||
if user_id is None:
|
||||
self.logger.error("Failed to register user!")
|
||||
user_id = -1
|
||||
self.logger.error("Failed to register user!")
|
||||
|
||||
else:
|
||||
card_id = await self.data.card.create_card(user_id, req.access_code)
|
||||
card_id = self.data.card.create_card(user_id, luid)
|
||||
|
||||
if card_id is None:
|
||||
self.logger.error("Failed to register card!")
|
||||
user_id = -1
|
||||
self.logger.error("Failed to register card!")
|
||||
|
||||
self.logger.info(
|
||||
f"Register access code {req.access_code} -> user_id {user_id}"
|
||||
f"register from {self.transport.getPeer().host}: luid {luid} -> user_id {user_id}"
|
||||
)
|
||||
|
||||
else:
|
||||
self.logger.info(
|
||||
f"Registration blocked!: access code {req.access_code}"
|
||||
f"register from {self.transport.getPeer().host} blocked!: luid {luid}"
|
||||
)
|
||||
|
||||
if user_id > 0:
|
||||
if (req.access_code.startswith("010") or req.access_code.startswith("3")) and req.serial_number != 0x04030201: # Default segatools sn:
|
||||
await self.data.card.set_chip_id_by_access_code(req.access_code, req.serial_number)
|
||||
self.logger.info(f"Attempt to set chip id to {req.serial_number} for access code {req.access_code}")
|
||||
|
||||
elif req.access_code.startswith("0008"):
|
||||
idm = self.data.card.to_idm(req.access_code)
|
||||
await self.data.card.set_idm_by_access_code(req.access_code, idm)
|
||||
self.logger.info(f"Attempt to set IDm to {idm} for access code {req.access_code}")
|
||||
user_id = -1
|
||||
|
||||
resp = ADBLookupResponse.from_req(req.head, user_id)
|
||||
if resp.user_id <= 0:
|
||||
resp.head.status = ADBStatus.BAN_SYS # Closest we can get to a "You cannot register"
|
||||
ret = struct.pack(
|
||||
"<5H",
|
||||
0xA13E,
|
||||
0x3087,
|
||||
self.AIMEDB_RESPONSE_CODES["lookup"],
|
||||
0x0030,
|
||||
0x0001 if user_id > -1 else 0,
|
||||
)
|
||||
ret += bytes(0x20 - len(ret))
|
||||
ret += struct.pack("<l", user_id)
|
||||
|
||||
else:
|
||||
await self.data.card.update_card_last_login(req.access_code)
|
||||
return self.append_padding(ret)
|
||||
|
||||
return resp
|
||||
def handle_log(self, data: bytes) -> bytes:
|
||||
# TODO: Save aimedb logs
|
||||
self.logger.info(f"log from {self.transport.getPeer().host}")
|
||||
ret = struct.pack(
|
||||
"<5H", 0xA13E, 0x3087, self.AIMEDB_RESPONSE_CODES["log"], 0x0020, 0x0001
|
||||
)
|
||||
return self.append_padding(ret)
|
||||
|
||||
# TODO: Save these in some capacity, as deemed relevant
|
||||
async def handle_status_log(self, data: bytes, resp_code: int) -> bytes:
|
||||
req = ADBStatusLogRequest(data)
|
||||
self.logger.info(f"User {req.aime_id} logged {req.status.name} event")
|
||||
return ADBBaseResponse(resp_code, 0x20, 1, req.head.game_id, req.head.store_id, req.head.keychip_id, req.head.protocol_ver)
|
||||
def handle_log2(self, data: bytes) -> bytes:
|
||||
self.logger.info(f"log2 from {self.transport.getPeer().host}")
|
||||
ret = struct.pack(
|
||||
"<5H", 0xA13E, 0x3087, self.AIMEDB_RESPONSE_CODES["log2"], 0x0040, 0x0001
|
||||
)
|
||||
ret += bytes(22)
|
||||
ret += struct.pack("H", 1)
|
||||
|
||||
async def handle_log(self, data: bytes, resp_code: int) -> bytes:
|
||||
req = ADBLogRequest(data)
|
||||
self.logger.info(f"User {req.aime_id} logged {req.status.name} event, credit_ct: {req.credit_ct} bet_ct: {req.bet_ct} won_ct: {req.won_ct}")
|
||||
return ADBBaseResponse(resp_code, 0x20, 1, req.head.game_id, req.head.store_id, req.head.keychip_id, req.head.protocol_ver)
|
||||
return self.append_padding(ret)
|
||||
|
||||
async def handle_log_ex(self, data: bytes, resp_code: int) -> bytes:
|
||||
req = ADBLogExRequest(data)
|
||||
strs = []
|
||||
self.logger.info(f"Recieved {req.num_logs} or {len(req.logs)} logs")
|
||||
|
||||
for x in range(req.num_logs):
|
||||
self.logger.debug(f"User {req.logs[x].aime_id} logged {req.logs[x].status.name} event, credit_ct: {req.logs[x].credit_ct} bet_ct: {req.logs[x].bet_ct} won_ct: {req.logs[x].won_ct}")
|
||||
return ADBLogExResponse.from_req(req.head)
|
||||
|
||||
class AimedbFactory(Factory):
|
||||
protocol = AimedbProtocol
|
||||
|
||||
def __init__(self, cfg: CoreConfig) -> None:
|
||||
self.config = cfg
|
||||
log_fmt_str = "[%(asctime)s] Aimedb | %(levelname)s | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
self.logger = logging.getLogger("aimedb")
|
||||
|
||||
fileHandler = TimedRotatingFileHandler(
|
||||
"{0}/{1}.log".format(self.config.server.log_dir, "aimedb"),
|
||||
when="d",
|
||||
backupCount=10,
|
||||
)
|
||||
fileHandler.setFormatter(log_fmt)
|
||||
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(log_fmt)
|
||||
|
||||
self.logger.addHandler(fileHandler)
|
||||
self.logger.addHandler(consoleHandler)
|
||||
|
||||
self.logger.setLevel(self.config.aimedb.loglevel)
|
||||
coloredlogs.install(
|
||||
level=cfg.aimedb.loglevel, logger=self.logger, fmt=log_fmt_str
|
||||
)
|
||||
|
||||
if self.config.aimedb.key == "":
|
||||
self.logger.error("Please set 'key' field in your config file.")
|
||||
exit(1)
|
||||
|
||||
self.logger.info(f"Ready on port {self.config.aimedb.port}")
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
return AimedbProtocol(self.config)
|
||||
|
1296
core/allnet.py
1296
core/allnet.py
File diff suppressed because it is too large
Load Diff
104
core/app.py
104
core/app.py
@ -1,104 +0,0 @@
|
||||
import yaml
|
||||
import logging
|
||||
import coloredlogs
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from starlette.routing import Route
|
||||
from starlette.requests import Request
|
||||
from starlette.applications import Starlette
|
||||
from starlette.responses import PlainTextResponse
|
||||
from os import environ, path, mkdir, W_OK, access
|
||||
from typing import List
|
||||
|
||||
from core import CoreConfig, TitleServlet, MuchaServlet
|
||||
from core.allnet import AllnetServlet, BillingServlet
|
||||
from core.chimedb import ChimeServlet
|
||||
from core.frontend import FrontendServlet
|
||||
|
||||
async def dummy_rt(request: Request):
|
||||
return PlainTextResponse("Service OK")
|
||||
|
||||
cfg_dir = environ.get("ARTEMIS_CFG_DIR", "config")
|
||||
cfg: CoreConfig = CoreConfig()
|
||||
if path.exists(f"{cfg_dir}/core.yaml"):
|
||||
cfg.update(yaml.safe_load(open(f"{cfg_dir}/core.yaml")))
|
||||
|
||||
if not path.exists(cfg.server.log_dir):
|
||||
mkdir(cfg.server.log_dir)
|
||||
|
||||
if not access(cfg.server.log_dir, W_OK):
|
||||
print(
|
||||
f"Log directory {cfg.server.log_dir} NOT writable, please check permissions"
|
||||
)
|
||||
exit(1)
|
||||
|
||||
logger = logging.getLogger("core")
|
||||
log_fmt_str = "[%(asctime)s] Core | %(levelname)s | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
|
||||
fileHandler = TimedRotatingFileHandler(
|
||||
"{0}/{1}.log".format(cfg.server.log_dir, "core"), when="d", backupCount=10
|
||||
)
|
||||
fileHandler.setFormatter(log_fmt)
|
||||
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(log_fmt)
|
||||
|
||||
logger.addHandler(fileHandler)
|
||||
logger.addHandler(consoleHandler)
|
||||
|
||||
log_lv = logging.DEBUG if cfg.server.is_develop else logging.INFO
|
||||
logger.setLevel(log_lv)
|
||||
coloredlogs.install(level=log_lv, logger=logger, fmt=log_fmt_str)
|
||||
|
||||
logger.info(f"Artemis starting in {'develop' if cfg.server.is_develop else 'production'} mode")
|
||||
|
||||
title = TitleServlet(cfg, cfg_dir) # This has to be loaded first to load plugins
|
||||
mucha = MuchaServlet(cfg, cfg_dir)
|
||||
|
||||
route_lst: List[Route] = [
|
||||
# Mucha
|
||||
Route("/mucha_front/boardauth.do", mucha.handle_boardauth, methods=["POST"]),
|
||||
Route("/mucha_front/updatacheck.do", mucha.handle_updatecheck, methods=["POST"]),
|
||||
Route("/mucha_front/downloadstate.do", mucha.handle_dlstate, methods=["POST"]),
|
||||
# General
|
||||
Route("/", dummy_rt),
|
||||
Route("/robots.txt", FrontendServlet.robots)
|
||||
]
|
||||
|
||||
if not cfg.billing.standalone:
|
||||
billing = BillingServlet(cfg, cfg_dir)
|
||||
route_lst += [
|
||||
Route("/request", billing.handle_billing_request, methods=["POST"]),
|
||||
Route("/request/", billing.handle_billing_request, methods=["POST"]),
|
||||
]
|
||||
|
||||
if not cfg.allnet.standalone:
|
||||
allnet = AllnetServlet(cfg, cfg_dir)
|
||||
route_lst += [
|
||||
Route("/sys/servlet/PowerOn", allnet.handle_poweron, methods=["GET", "POST"]),
|
||||
Route("/net/initialize", allnet.handle_poweron, methods=["GET", "POST"]),
|
||||
Route("/sys/servlet/DownloadOrder", allnet.handle_dlorder, methods=["GET", "POST"]),
|
||||
Route("/net/delivery/instruction", allnet.handle_dlorder, methods=["GET", "POST"]),
|
||||
Route("/sys/servlet/LoaderStateRecorder", allnet.handle_loaderstaterecorder, methods=["GET", "POST"]),
|
||||
Route("/sys/servlet/Alive", allnet.handle_alive, methods=["GET", "POST"]),
|
||||
Route("/naomitest.html", allnet.handle_naomitest),
|
||||
]
|
||||
|
||||
if cfg.allnet.allow_online_updates:
|
||||
route_lst += [
|
||||
Route("/report-api/Report", allnet.handle_dlorder_report, methods=["POST"]),
|
||||
Route("/dl/ini/{file:str}", allnet.handle_dlorder_ini),
|
||||
]
|
||||
|
||||
if cfg.chimedb.enable:
|
||||
chimedb = ChimeServlet(cfg, cfg_dir)
|
||||
route_lst += [
|
||||
Route("/wc_aime/api/alive_check", chimedb.handle_qr_alive, methods=["POST"]),
|
||||
Route("/qrcode/api/alive_check", chimedb.handle_qr_alive, methods=["POST"]),
|
||||
Route("/wc_aime/api/get_data", chimedb.handle_qr_lookup, methods=["POST"])
|
||||
]
|
||||
|
||||
for code, game in title.title_registry.items():
|
||||
route_lst += game.get_routes()
|
||||
|
||||
app = Starlette(cfg.server.is_develop, route_lst)
|
139
core/chimedb.py
139
core/chimedb.py
@ -1,139 +0,0 @@
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
from enum import Enum
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
||||
import coloredlogs
|
||||
from starlette.responses import PlainTextResponse
|
||||
from starlette.requests import Request
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core.data import Data
|
||||
|
||||
class ChimeDBStatus(Enum):
|
||||
NONE = 0
|
||||
READER_SETUP_FAIL = 1
|
||||
READER_ACCESS_FAIL = 2
|
||||
READER_INCOMPATIBLE = 3
|
||||
DB_RESOLVE_FAIL = 4
|
||||
DB_ACCESS_TIMEOUT = 5
|
||||
DB_ACCESS_FAIL = 6
|
||||
AIME_ID_INVALID = 7
|
||||
NO_BOARD_INFO = 8
|
||||
LOCK_BAN_SYSTEM_USER = 9
|
||||
LOCK_BAN_SYSTEM = 10
|
||||
LOCK_BAN_USER = 11
|
||||
LOCK_BAN = 12
|
||||
LOCK_SYSTEM_USER = 13
|
||||
LOCK_SYSTEM = 14
|
||||
LOCK_USER = 15
|
||||
|
||||
class ChimeServlet:
|
||||
def __init__(self, core_cfg: CoreConfig, cfg_folder: str) -> None:
|
||||
self.config = core_cfg
|
||||
self.config_folder = cfg_folder
|
||||
|
||||
self.data = Data(core_cfg)
|
||||
|
||||
self.logger = logging.getLogger("chimedb")
|
||||
if not hasattr(self.logger, "initted"):
|
||||
log_fmt_str = "[%(asctime)s] Chimedb | %(levelname)s | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
|
||||
fileHandler = TimedRotatingFileHandler(
|
||||
"{0}/{1}.log".format(self.config.server.log_dir, "chimedb"),
|
||||
when="d",
|
||||
backupCount=10,
|
||||
)
|
||||
fileHandler.setFormatter(log_fmt)
|
||||
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(log_fmt)
|
||||
|
||||
self.logger.addHandler(fileHandler)
|
||||
self.logger.addHandler(consoleHandler)
|
||||
|
||||
self.logger.setLevel(self.config.aimedb.loglevel)
|
||||
coloredlogs.install(
|
||||
level=core_cfg.aimedb.loglevel, logger=self.logger, fmt=log_fmt_str
|
||||
)
|
||||
self.logger.initted = True
|
||||
|
||||
if not core_cfg.chimedb.key:
|
||||
self.logger.error("!!!KEY NOT SET!!!")
|
||||
exit(1)
|
||||
|
||||
self.logger.info("Serving")
|
||||
|
||||
async def handle_qr_alive(self, request: Request):
|
||||
return PlainTextResponse("alive")
|
||||
|
||||
async def handle_qr_lookup(self, request: Request) -> bytes:
|
||||
req = json.loads(await request.body())
|
||||
access_code = req["qrCode"][-20:]
|
||||
timestamp = req["timestamp"]
|
||||
|
||||
try:
|
||||
userId = await self._lookup(access_code)
|
||||
data = json.dumps({
|
||||
"userID": userId,
|
||||
"errorID": 0,
|
||||
"timestamp": timestamp,
|
||||
"key": self._hash_key(userId, timestamp)
|
||||
})
|
||||
except Exception as e:
|
||||
|
||||
self.logger.error(e.with_traceback(None))
|
||||
|
||||
data = json.dumps({
|
||||
"userID": -1,
|
||||
"errorID": ChimeDBStatus.DB_ACCESS_FAIL,
|
||||
"timestamp": timestamp,
|
||||
"key": self._hash_key(-1, timestamp)
|
||||
})
|
||||
|
||||
return PlainTextResponse(data)
|
||||
|
||||
def _hash_key(self, chip_id, timestamp):
|
||||
input_string = f"{chip_id}{timestamp}{self.config.chimedb.key}"
|
||||
hash_object = hashlib.sha256(input_string.encode('utf-8'))
|
||||
hex_dig = hash_object.hexdigest()
|
||||
|
||||
formatted_hex = format(int(hex_dig, 16), '064x').upper()
|
||||
|
||||
return formatted_hex
|
||||
|
||||
async def _lookup(self, access_code):
|
||||
user_id = await self.data.card.get_user_id_from_card(access_code)
|
||||
|
||||
self.logger.info(f"access_code {access_code} -> user_id {user_id}")
|
||||
|
||||
if not user_id or user_id <= 0:
|
||||
user_id = await self._register(access_code)
|
||||
|
||||
return user_id
|
||||
|
||||
async def _register(self, access_code):
|
||||
user_id = -1
|
||||
|
||||
if self.config.server.allow_user_registration:
|
||||
user_id = await self.data.user.create_user()
|
||||
|
||||
if user_id is None:
|
||||
self.logger.error("Failed to register user!")
|
||||
user_id = -1
|
||||
else:
|
||||
card_id = await self.data.card.create_card(user_id, access_code)
|
||||
|
||||
if card_id is None:
|
||||
self.logger.error("Failed to register card!")
|
||||
user_id = -1
|
||||
|
||||
self.logger.info(
|
||||
f"Register access code {access_code} -> user_id {user_id}"
|
||||
)
|
||||
else:
|
||||
self.logger.info(f"Registration blocked!: access code {access_code}")
|
||||
|
||||
return user_id
|
324
core/config.py
324
core/config.py
@ -1,9 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import ssl
|
||||
from typing import Any, Union, Dict
|
||||
import logging, os
|
||||
from typing import Any
|
||||
|
||||
from typing_extensions import Optional
|
||||
|
||||
class ServerConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
@ -11,42 +8,9 @@ class ServerConfig:
|
||||
|
||||
@property
|
||||
def listen_address(self) -> str:
|
||||
"""
|
||||
Address Artemis will bind to and listen on
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "listen_address", default="127.0.0.1"
|
||||
)
|
||||
|
||||
@property
|
||||
def hostname(self) -> str:
|
||||
"""
|
||||
Hostname sent to games
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "hostname", default="localhost"
|
||||
)
|
||||
|
||||
@property
|
||||
def port(self) -> int:
|
||||
"""
|
||||
Port the game will listen on
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "port", default=80
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_key(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "ssl_key", default="cert/title.key"
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_cert(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "ssl_cert", default="cert/title.pem"
|
||||
)
|
||||
|
||||
@property
|
||||
def allow_user_registration(self) -> bool:
|
||||
@ -72,49 +36,12 @@ class ServerConfig:
|
||||
self.__config, "core", "server", "is_develop", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def is_using_proxy(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "is_using_proxy", default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def proxy_port(self) -> int:
|
||||
"""
|
||||
What port the proxy is listening on. This will be sent instead of 'port' if
|
||||
is_using_proxy is True and this value is non-zero
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "proxy_port", default=0
|
||||
)
|
||||
|
||||
@property
|
||||
def proxy_port_ssl(self) -> int:
|
||||
"""
|
||||
What port the proxy is listening for secure connections on. This will be sent
|
||||
instead of 'port' if is_using_proxy is True and this value is non-zero
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "proxy_port_ssl", default=0
|
||||
)
|
||||
|
||||
@property
|
||||
def log_dir(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "log_dir", default="logs"
|
||||
)
|
||||
|
||||
@property
|
||||
def check_arcade_ip(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "check_arcade_ip", default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def strict_ip_checking(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "server", "strict_ip_checking", default=False
|
||||
)
|
||||
|
||||
class TitleConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
@ -129,17 +56,18 @@ class TitleConfig:
|
||||
)
|
||||
|
||||
@property
|
||||
def reboot_start_time(self) -> str:
|
||||
def hostname(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "title", "reboot_start_time", default=""
|
||||
self.__config, "core", "title", "hostname", default="localhost"
|
||||
)
|
||||
|
||||
@property
|
||||
def reboot_end_time(self) -> str:
|
||||
def port(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "title", "reboot_end_time", default=""
|
||||
self.__config, "core", "title", "port", default=8080
|
||||
)
|
||||
|
||||
|
||||
class DatabaseConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
@ -177,61 +105,7 @@ class DatabaseConfig:
|
||||
@property
|
||||
def protocol(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "protocol", default="mysql"
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_enabled(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_enabled", default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_cafile(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_cafile", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_capath(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_capath", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_cert(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_cert", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_key(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_key", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_key_password(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_key_password", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_verify_identity(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_verify_identity", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_verify_cert(self) -> Optional[Union[str, bool]]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_verify_cert", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def ssl_ciphers(self) -> Optional[str]:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "ssl_ciphers", default=None
|
||||
self.__config, "core", "database", "type", default="mysql"
|
||||
)
|
||||
|
||||
@property
|
||||
@ -249,9 +123,13 @@ class DatabaseConfig:
|
||||
)
|
||||
|
||||
@property
|
||||
def enable_memcached(self) -> bool:
|
||||
def user_table_autoincrement_start(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "database", "enable_memcached", default=True
|
||||
self.__config,
|
||||
"core",
|
||||
"database",
|
||||
"user_table_autoincrement_start",
|
||||
default=10000,
|
||||
)
|
||||
|
||||
@property
|
||||
@ -260,59 +138,13 @@ class DatabaseConfig:
|
||||
self.__config, "core", "database", "memcached_host", default="localhost"
|
||||
)
|
||||
|
||||
def create_ssl_context_if_enabled(self):
|
||||
if not self.ssl_enabled:
|
||||
return
|
||||
|
||||
no_ca = (
|
||||
self.ssl_cafile is None
|
||||
and self.ssl_capath is None
|
||||
)
|
||||
|
||||
ctx = ssl.create_default_context(
|
||||
cafile=self.ssl_cafile,
|
||||
capath=self.ssl_capath,
|
||||
)
|
||||
ctx.check_hostname = not no_ca and self.ssl_verify_identity
|
||||
|
||||
if self.ssl_verify_cert is None:
|
||||
ctx.verify_mode = ssl.CERT_NONE if no_ca else ssl.CERT_REQUIRED
|
||||
elif isinstance(self.ssl_verify_cert, bool):
|
||||
ctx.verify_mode = (
|
||||
ssl.CERT_REQUIRED
|
||||
if self.ssl_verify_cert
|
||||
else ssl.CERT_NONE
|
||||
)
|
||||
elif isinstance(self.ssl_verify_cert, str):
|
||||
value = self.ssl_verify_cert.lower()
|
||||
|
||||
if value in ("none", "0", "false", "no"):
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
elif value == "optional":
|
||||
ctx.verify_mode = ssl.CERT_OPTIONAL
|
||||
elif value in ("required", "1", "true", "yes"):
|
||||
ctx.verify_mode = ssl.CERT_REQUIRED
|
||||
else:
|
||||
ctx.verify_mode = ssl.CERT_NONE if no_ca else ssl.CERT_REQUIRED
|
||||
|
||||
if self.ssl_cert:
|
||||
ctx.load_cert_chain(
|
||||
self.ssl_cert,
|
||||
self.ssl_key,
|
||||
self.ssl_key_password,
|
||||
)
|
||||
|
||||
if self.ssl_ciphers:
|
||||
ctx.set_ciphers(self.ssl_ciphers)
|
||||
|
||||
return ctx
|
||||
|
||||
class FrontendConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def enable(self) -> bool:
|
||||
def enable(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "frontend", "enable", default=False
|
||||
)
|
||||
@ -320,7 +152,7 @@ class FrontendConfig:
|
||||
@property
|
||||
def port(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "frontend", "port", default=8080
|
||||
self.__config, "core", "frontend", "port", default=8090
|
||||
)
|
||||
|
||||
@property
|
||||
@ -330,29 +162,12 @@ class FrontendConfig:
|
||||
self.__config, "core", "frontend", "loglevel", default="info"
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def secret(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "frontend", "secret", default=""
|
||||
)
|
||||
|
||||
|
||||
class AllnetConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def standalone(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "standalone", default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def port(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "port", default=80
|
||||
)
|
||||
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
@ -362,7 +177,13 @@ class AllnetConfig:
|
||||
)
|
||||
|
||||
@property
|
||||
def allow_online_updates(self) -> bool:
|
||||
def port(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "port", default=80
|
||||
)
|
||||
|
||||
@property
|
||||
def allow_online_updates(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "allow_online_updates", default=False
|
||||
)
|
||||
@ -373,34 +194,10 @@ class AllnetConfig:
|
||||
self.__config, "core", "allnet", "update_cfg_folder", default=""
|
||||
)
|
||||
|
||||
@property
|
||||
def save_billing(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "save_billing", default=False
|
||||
)
|
||||
@property
|
||||
def allnet_lite_keys(self) -> Dict:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "allnet", "allnet_lite_keys", default={}
|
||||
)
|
||||
|
||||
class BillingConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def standalone(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "billing", "standalone", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
CoreConfig.get_config_field(
|
||||
self.__config, "core", "billing", "loglevel", default="info"
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def port(self) -> int:
|
||||
@ -426,22 +223,11 @@ class BillingConfig:
|
||||
self.__config, "core", "billing", "signing_key", default="cert/billing.key"
|
||||
)
|
||||
|
||||
|
||||
class AimedbConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def enable(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "aimedb", "enable", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def listen_address(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "aimedb", "listen_address", default=""
|
||||
)
|
||||
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
@ -462,44 +248,17 @@ class AimedbConfig:
|
||||
self.__config, "core", "aimedb", "key", default=""
|
||||
)
|
||||
|
||||
@property
|
||||
def id_secret(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "aimedb", "id_secret", default=""
|
||||
)
|
||||
|
||||
@property
|
||||
def id_lifetime_seconds(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "aimedb", "id_lifetime_seconds", default=86400
|
||||
)
|
||||
|
||||
class ChimedbConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def enable(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "chimedb", "enable", default=True
|
||||
)
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
CoreConfig.get_config_field(
|
||||
self.__config, "core", "chimedb", "loglevel", default="info"
|
||||
)
|
||||
)
|
||||
@property
|
||||
def key(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "chimedb", "key", default=""
|
||||
)
|
||||
|
||||
class MuchaConfig:
|
||||
def __init__(self, parent_config: "CoreConfig") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def enable(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "mucha", "enable", default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def loglevel(self) -> int:
|
||||
return CoreConfig.str_to_loglevel(
|
||||
@ -508,6 +267,13 @@ class MuchaConfig:
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def hostname(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "core", "mucha", "hostname", default="localhost"
|
||||
)
|
||||
|
||||
|
||||
class CoreConfig(dict):
|
||||
def __init__(self) -> None:
|
||||
self.server = ServerConfig(self)
|
||||
@ -517,7 +283,6 @@ class CoreConfig(dict):
|
||||
self.allnet = AllnetConfig(self)
|
||||
self.billing = BillingConfig(self)
|
||||
self.aimedb = AimedbConfig(self)
|
||||
self.chimedb = ChimedbConfig(self)
|
||||
self.mucha = MuchaConfig(self)
|
||||
|
||||
@classmethod
|
||||
@ -530,19 +295,6 @@ class CoreConfig(dict):
|
||||
return logging.DEBUG
|
||||
else:
|
||||
return logging.INFO
|
||||
|
||||
@classmethod
|
||||
def loglevel_to_str(cls, level: int) -> str:
|
||||
if level == logging.ERROR:
|
||||
return "error"
|
||||
elif level == logging.WARN:
|
||||
return "warn"
|
||||
elif level == logging.INFO:
|
||||
return "info"
|
||||
elif level == logging.DEBUG:
|
||||
return "debug"
|
||||
else:
|
||||
return "notset"
|
||||
|
||||
@classmethod
|
||||
def get_config_field(
|
||||
|
@ -1,18 +1,16 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MainboardPlatformCodes(Enum):
|
||||
RINGEDGE = "AAL"
|
||||
RINGEDGE2 = "AAS"
|
||||
RINGWIDE = "AAM"
|
||||
NU = "AAV"
|
||||
NUSX = "AAW"
|
||||
ALLS = "ACA"
|
||||
#ALLS_UX = "ACAE"
|
||||
#ALLS_HX = "ACAX"
|
||||
class MainboardPlatformCodes:
|
||||
RINGEDGE = "AALE"
|
||||
RINGWIDE = "AAML"
|
||||
NU = "AAVE"
|
||||
NUSX = "AAWE"
|
||||
ALLS_UX = "ACAE"
|
||||
ALLS_HX = "ACAX"
|
||||
|
||||
|
||||
class MainboardRevisions(Enum):
|
||||
class MainboardRevisions:
|
||||
RINGEDGE = 1
|
||||
RINGEDGE2 = 2
|
||||
|
||||
@ -31,10 +29,11 @@ class MainboardRevisions(Enum):
|
||||
ALLS_HX2 = 12
|
||||
|
||||
|
||||
class KeychipPlatformsCodes(Enum):
|
||||
RING = "72"
|
||||
NU = ("60", "61", "69")
|
||||
ALLS = "63"
|
||||
class KeychipPlatformsCodes:
|
||||
RING = "A72E"
|
||||
NU = ("A60E", "A60E", "A60E")
|
||||
NUSX = ("A61X", "A69X")
|
||||
ALLS = "A63E"
|
||||
|
||||
|
||||
class AllnetCountryCode(Enum):
|
||||
@ -45,14 +44,6 @@ class AllnetCountryCode(Enum):
|
||||
SOUTH_KOREA = "KOR"
|
||||
TAIWAN = "TWN"
|
||||
CHINA = "CHN"
|
||||
AUSTRALIA = "AUS"
|
||||
INDONESIA = "IDN"
|
||||
MYANMAR = "MMR"
|
||||
MALAYSIA = "MYS"
|
||||
NEW_ZEALAND = "NZL"
|
||||
PHILIPPINES = "PHL"
|
||||
THAILAND = "THA"
|
||||
VIETNAM = "VNM"
|
||||
|
||||
|
||||
class AllnetJapanRegionId(Enum):
|
||||
|
@ -1 +0,0 @@
|
||||
Generic single-database configuration.
|
@ -1,64 +0,0 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
script_location=.
|
||||
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# max length of characters to apply to the
|
||||
# "slug" field
|
||||
#truncate_slug_length = 40
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
# set to 'true' to allow .pyc and .pyo files without
|
||||
# a source .py file to be detected as revisions in the
|
||||
# versions/ directory
|
||||
# sourceless = false
|
||||
|
||||
# version location specification; this defaults
|
||||
# to migrations//versions. When using multiple version
|
||||
# directories, initial revisions must be specified with --version-path
|
||||
# version_locations = %(here)s/bar %(here)s/bat migrations//versions
|
||||
|
||||
# the output encoding used when revision files
|
||||
# are written from script.py.mako
|
||||
# output_encoding = utf-8
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
@ -1,121 +0,0 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
import threading
|
||||
from logging.config import fileConfig
|
||||
|
||||
import yaml
|
||||
from alembic import context
|
||||
from sqlalchemy import pool
|
||||
from sqlalchemy.engine import Connection
|
||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core.data.schema.base import metadata
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
raise Exception("Not implemented or configured!")
|
||||
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def do_run_migrations(connection: Connection) -> None:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
compare_type=True,
|
||||
compare_server_default=True,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
async def run_async_migrations() -> None:
|
||||
"""In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
ini_section = config.get_section(config.config_ini_section)
|
||||
overrides = context.get_x_argument(as_dictionary=True)
|
||||
for override in overrides:
|
||||
ini_section[override] = overrides[override]
|
||||
|
||||
core_config = CoreConfig()
|
||||
|
||||
with (Path("../../..") / os.environ["ARTEMIS_CFG_DIR"] / "core.yaml").open(encoding="utf-8") as f:
|
||||
core_config.update(yaml.safe_load(f))
|
||||
|
||||
connectable = async_engine_from_config(
|
||||
ini_section,
|
||||
poolclass=pool.NullPool,
|
||||
connect_args={
|
||||
"charset": "utf8mb4",
|
||||
"ssl": core_config.database.create_ssl_context_if_enabled(),
|
||||
}
|
||||
)
|
||||
|
||||
async with connectable.connect() as connection:
|
||||
await connection.run_sync(do_run_migrations)
|
||||
|
||||
await connectable.dispose()
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
# there's no event loop
|
||||
asyncio.run(run_async_migrations())
|
||||
else:
|
||||
# there's currently an event loop and trying to wait for a coroutine
|
||||
# to finish without using `await` is pretty wormy. nested event loops
|
||||
# are explicitly forbidden by asyncio.
|
||||
#
|
||||
# take the easy way out, spawn it in another thread.
|
||||
thread = threading.Thread(target=asyncio.run, args=(run_async_migrations(),))
|
||||
thread.start()
|
||||
thread.join()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
@ -1,24 +0,0 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
@ -1,30 +0,0 @@
|
||||
"""ONGEKI update ongeki_static_tech_music_uk
|
||||
|
||||
Revision ID: 1d0014d35220
|
||||
Revises: 91c682918b67
|
||||
Create Date: 2025-03-26 20:44:55.590992
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1d0014d35220'
|
||||
down_revision = '91c682918b67'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('ongeki_static_tech_music_uk', 'ongeki_static_tech_music', type_='unique')
|
||||
op.create_unique_constraint('ongeki_static_tech_music_uk', 'ongeki_static_tech_music', ['version', 'eventId', 'musicId', 'level'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('ongeki_static_tech_music_uk', 'ongeki_static_tech_music', type_='unique')
|
||||
op.create_unique_constraint('ongeki_static_tech_music_uk', 'ongeki_static_tech_music', ['version', 'musicId'])
|
||||
# ### end Alembic commands ###
|
@ -1,27 +0,0 @@
|
||||
"""chuni_add_net_battle_uk
|
||||
|
||||
Revision ID: 1e150d16ab6b
|
||||
Revises: b23f985100ba
|
||||
Create Date: 2024-06-21 22:57:18.418488
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1e150d16ab6b'
|
||||
down_revision = 'b23f985100ba'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint(None, 'chuni_profile_net_battle', ['user'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'chuni_profile_net_battle', type_='unique')
|
||||
# ### end Alembic commands ###
|
@ -1,164 +0,0 @@
|
||||
"""acc_opt_tables
|
||||
|
||||
Revision ID: 263884e774cc
|
||||
Revises: 1d0014d35220
|
||||
Create Date: 2025-04-07 18:05:53.349320
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '263884e774cc'
|
||||
down_revision = '1d0014d35220'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('chuni_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='chuni_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('cm_static_opts',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=True),
|
||||
sa.Column('gekiVersion', sa.INTEGER(), nullable=True),
|
||||
sa.Column('gekiReleaseVer', sa.INTEGER(), nullable=True),
|
||||
sa.Column('maiVersion', sa.INTEGER(), nullable=True),
|
||||
sa.Column('maiReleaseVer', sa.INTEGER(), nullable=True),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='cm_static_opts_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('mai2_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('cmReleaseVer', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='mai2_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('ongeki_static_opt',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=4), nullable=False),
|
||||
sa.Column('sequence', sa.INTEGER(), nullable=False),
|
||||
sa.Column('cmReleaseVer', sa.INTEGER(), nullable=False),
|
||||
sa.Column('whenRead', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('isEnable', sa.BOOLEAN(), server_default='1', nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'name', name='ongeki_static_opt_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('chuni_static_avatar', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_avatar', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_cards', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_character', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_character', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_charge', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_charge', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_events', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_events', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_gachas', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_gachas', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_login_bonus', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_login_bonus', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_login_bonus_preset', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_login_bonus_preset', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_map_icon', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_map_icon', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_music', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_system_voice', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_system_voice', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('chuni_static_trophy', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_trophy', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_cards', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_event', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_event', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_music', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('mai2_static_ticket', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'mai2_static_ticket', 'mai2_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_cards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_cards', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_events', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_events', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_gachas', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_gachas', 'cm_static_opts', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_music', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_music', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
op.add_column('ongeki_static_rewards', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'ongeki_static_rewards', 'ongeki_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("ongeki_static_rewards_ibfk_1", 'ongeki_static_rewards', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_rewards', 'opt')
|
||||
op.drop_constraint("ongeki_static_music_ibfk_1", 'ongeki_static_music', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_music', 'opt')
|
||||
op.drop_constraint("ongeki_static_gachas_ibfk_1", 'ongeki_static_gachas', type_='foreignkey')
|
||||
op.drop_column('ongeki_static_gachas', 'opt')
|
||||
op.drop_constraint("ongeki_static_events_ibfk_1", "ongeki_static_events", type_='foreignkey')
|
||||
op.drop_column('ongeki_static_events', 'opt')
|
||||
op.drop_constraint("ongeki_static_cards_ibfk_1", "ongeki_static_cards", type_='foreignkey')
|
||||
op.drop_column('ongeki_static_cards', 'opt')
|
||||
op.drop_constraint("mai2_static_ticket_ibfk_1", "mai2_static_ticket", type_='foreignkey')
|
||||
op.drop_column('mai2_static_ticket', 'opt')
|
||||
op.drop_constraint("mai2_static_music_ibfk_1", "mai2_static_music", type_='foreignkey')
|
||||
op.drop_column('mai2_static_music', 'opt')
|
||||
op.drop_constraint("mai2_static_event_ibfk_1", "mai2_static_event", type_='foreignkey')
|
||||
op.drop_column('mai2_static_event', 'opt')
|
||||
op.drop_constraint("mai2_static_cards_ibfk_1", "mai2_static_cards", type_='foreignkey')
|
||||
op.drop_column('mai2_static_cards', 'opt')
|
||||
op.drop_constraint("chuni_static_trophy_ibfk_1", "chuni_static_trophy", type_='foreignkey')
|
||||
op.drop_column('chuni_static_trophy', 'opt')
|
||||
op.drop_constraint("chuni_static_system_voice_ibfk_1", "chuni_static_system_voice", type_='foreignkey')
|
||||
op.drop_column('chuni_static_system_voice', 'opt')
|
||||
op.drop_constraint("chuni_static_music_ibfk_1", "chuni_static_music", type_='foreignkey')
|
||||
op.drop_column('chuni_static_music', 'opt')
|
||||
op.drop_constraint("chuni_static_map_icon_ibfk_1", "chuni_static_map_icon", type_='foreignkey')
|
||||
op.drop_column('chuni_static_map_icon', 'opt')
|
||||
op.drop_constraint("chuni_static_login_bonus_preset_ibfk_1", "chuni_static_login_bonus_preset", type_='foreignkey')
|
||||
op.drop_column('chuni_static_login_bonus_preset', 'opt')
|
||||
op.drop_constraint("chuni_static_login_bonus_ibfk_2", "chuni_static_login_bonus", type_='foreignkey')
|
||||
op.drop_column('chuni_static_login_bonus', 'opt')
|
||||
op.drop_constraint("chuni_static_gachas_ibfk_1", "chuni_static_gachas", type_='foreignkey')
|
||||
op.drop_column('chuni_static_gachas', 'opt')
|
||||
op.drop_constraint("chuni_static_events_ibfk_1", "chuni_static_events", type_='foreignkey')
|
||||
op.drop_column('chuni_static_events', 'opt')
|
||||
op.drop_constraint("chuni_static_charge_ibfk_1", "chuni_static_charge", type_='foreignkey')
|
||||
op.drop_column('chuni_static_charge', 'opt')
|
||||
op.drop_constraint("chuni_static_character_ibfk_1", "chuni_static_character", type_='foreignkey')
|
||||
op.drop_column('chuni_static_character', 'opt')
|
||||
op.drop_constraint("chuni_static_cards_ibfk_1", "chuni_static_cards", type_='foreignkey')
|
||||
op.drop_column('chuni_static_cards', 'opt')
|
||||
op.drop_constraint("chuni_static_avatar_ibfk_1", "chuni_static_avatar", type_='foreignkey')
|
||||
op.drop_column('chuni_static_avatar', 'opt')
|
||||
op.drop_table('ongeki_static_opt')
|
||||
op.drop_table('mai2_static_opt')
|
||||
op.drop_table('cm_static_opts')
|
||||
op.drop_table('chuni_static_opt')
|
||||
# ### end Alembic commands ###
|
@ -1,66 +0,0 @@
|
||||
"""add_billing_tables
|
||||
|
||||
Revision ID: 27e3434740df
|
||||
Revises: ae364c078429
|
||||
Create Date: 2025-04-17 18:32:06.008601
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '27e3434740df'
|
||||
down_revision = 'ae364c078429'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('machine_billing_charge',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('game_id', sa.CHAR(length=5), nullable=False),
|
||||
sa.Column('game_ver', sa.FLOAT(), nullable=False),
|
||||
sa.Column('play_count', sa.INTEGER(), nullable=False),
|
||||
sa.Column('play_limit', sa.INTEGER(), nullable=False),
|
||||
sa.Column('product_code', sa.INTEGER(), nullable=False),
|
||||
sa.Column('product_count', sa.INTEGER(), nullable=False),
|
||||
sa.Column('func_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('player_number', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('machine_billing_credit',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('chute_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('service_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('operation_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_rate0', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_rate1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_bonus', sa.INTEGER(), nullable=False),
|
||||
sa.Column('credit_rate', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot0', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot3', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot4', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot5', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot6', sa.INTEGER(), nullable=False),
|
||||
sa.Column('coin_count_slot7', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('machine'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('machine_billing_credit')
|
||||
op.drop_table('machine_billing_charge')
|
||||
# ### end Alembic commands ###
|
@ -1,28 +0,0 @@
|
||||
"""mai2_buddies_plus
|
||||
|
||||
Revision ID: 28443e2da5b8
|
||||
Revises: 5ea73f89d982
|
||||
Create Date: 2024-09-15 20:44:02.351819
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '28443e2da5b8'
|
||||
down_revision = '5ea73f89d982'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('mai2_profile_detail', sa.Column('point', sa.Integer()))
|
||||
op.add_column('mai2_profile_detail', sa.Column('totalPoint', sa.Integer()))
|
||||
op.add_column('mai2_profile_detail', sa.Column('friendRegistSkip', sa.SmallInteger()))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('mai2_profile_detail', 'point')
|
||||
op.drop_column('mai2_profile_detail', 'totalPoint')
|
||||
op.drop_column('mai2_profile_detail', 'friendRegistSkip')
|
@ -1,48 +0,0 @@
|
||||
"""add_event_log_info
|
||||
|
||||
Revision ID: 2bf9f38d9444
|
||||
Revises: 81e44dd6047a
|
||||
Create Date: 2024-05-21 23:00:17.468407
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2bf9f38d9444'
|
||||
down_revision = '81e44dd6047a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('event_log', sa.Column('user', sa.INTEGER(), nullable=True))
|
||||
op.add_column('event_log', sa.Column('arcade', sa.INTEGER(), nullable=True))
|
||||
op.add_column('event_log', sa.Column('machine', sa.INTEGER(), nullable=True))
|
||||
op.add_column('event_log', sa.Column('ip', sa.TEXT(length=39), nullable=True))
|
||||
op.alter_column('event_log', 'when_logged',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.create_foreign_key(None, 'event_log', 'machine', ['machine'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'event_log', 'arcade', ['arcade'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'event_log', 'aime_user', ['user'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'event_log', type_='foreignkey')
|
||||
op.drop_constraint(None, 'event_log', type_='foreignkey')
|
||||
op.drop_constraint(None, 'event_log', type_='foreignkey')
|
||||
op.alter_column('event_log', 'when_logged',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('current_timestamp()'),
|
||||
existing_nullable=False)
|
||||
op.drop_column('event_log', 'ip')
|
||||
op.drop_column('event_log', 'machine')
|
||||
op.drop_column('event_log', 'arcade')
|
||||
op.drop_column('event_log', 'user')
|
||||
# ### end Alembic commands ###
|
@ -1,46 +0,0 @@
|
||||
"""add_event_log_game_version
|
||||
|
||||
Revision ID: 2d024cf145a1
|
||||
Revises: 2bf9f38d9444
|
||||
Create Date: 2024-05-21 23:41:31.445331
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2d024cf145a1'
|
||||
down_revision = '2bf9f38d9444'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('event_log', sa.Column('game', sa.TEXT(length=4), nullable=True))
|
||||
op.add_column('event_log', sa.Column('version', sa.TEXT(length=24), nullable=True))
|
||||
op.alter_column('event_log', 'ip',
|
||||
existing_type=mysql.TINYTEXT(),
|
||||
type_=sa.TEXT(length=39),
|
||||
existing_nullable=True)
|
||||
op.alter_column('event_log', 'when_logged',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('event_log', 'when_logged',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('current_timestamp()'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('event_log', 'ip',
|
||||
existing_type=sa.TEXT(length=39),
|
||||
type_=mysql.TINYTEXT(),
|
||||
existing_nullable=True)
|
||||
op.drop_column('event_log', 'version')
|
||||
op.drop_column('event_log', 'game')
|
||||
# ### end Alembic commands ###
|
@ -1,54 +0,0 @@
|
||||
"""pokken_fix_pokemon_uk
|
||||
|
||||
Revision ID: 3657efefc5a4
|
||||
Revises: 4a02e623e5e6
|
||||
Create Date: 2024-06-13 23:50:57.611998
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3657efefc5a4'
|
||||
down_revision = '4a02e623e5e6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('pokken_pokemon_data', 'char_id',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=True)
|
||||
op.alter_column('pokken_pokemon_data', 'illustration_book_no',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=False)
|
||||
op.drop_constraint('pokken_pokemon_data_ibfk_1', table_name='pokken_pokemon_data', type_='foreignkey')
|
||||
op.drop_index('pokken_pokemon_data_uk', table_name='pokken_pokemon_data')
|
||||
op.create_unique_constraint('pokken_pokemon_uk', 'pokken_pokemon_data', ['user', 'illustration_book_no'])
|
||||
op.create_foreign_key("pokken_pokemon_data_ibfk_1", "pokken_pokemon_data", "aime_user", ['user'], ['id'])
|
||||
op.alter_column('pokken_profile', 'trainer_name',
|
||||
existing_type=mysql.VARCHAR(length=16),
|
||||
type_=sa.String(length=14),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('pokken_profile', 'trainer_name',
|
||||
existing_type=sa.String(length=14),
|
||||
type_=mysql.VARCHAR(length=16),
|
||||
existing_nullable=True)
|
||||
op.drop_constraint('pokken_pokemon_data_ibfk_1', table_name='pokken_pokemon_data', type_='foreignkey')
|
||||
op.drop_constraint('pokken_pokemon_uk', 'pokken_pokemon_data', type_='unique')
|
||||
op.create_index('pokken_pokemon_data_uk', 'pokken_pokemon_data', ['user', 'char_id'], unique=True)
|
||||
op.create_foreign_key("pokken_pokemon_data_ibfk_1", "pokken_pokemon_data", "aime_user", ['user'], ['id'])
|
||||
op.alter_column('pokken_pokemon_data', 'illustration_book_no',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=True)
|
||||
op.alter_column('pokken_pokemon_data', 'char_id',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=False)
|
||||
# ### end Alembic commands ###
|
@ -1,122 +0,0 @@
|
||||
"""chuni_ui_overhaul
|
||||
|
||||
Revision ID: 41f77ef50588
|
||||
Revises: d8cd1fa04c2a
|
||||
Create Date: 2024-11-02 13:27:45.839787
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '41f77ef50588'
|
||||
down_revision = 'd8cd1fa04c2a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('chuni_static_avatar', sa.Column('sortName', mysql.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('chuni_static_avatar', sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True))
|
||||
op.add_column('chuni_static_avatar', sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True))
|
||||
|
||||
op.create_table('chuni_static_character',
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('characterId', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('sortName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('worksName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('rareType', mysql.INTEGER(display_width=11), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.Column('imagePath1', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('imagePath2', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('imagePath3', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True),
|
||||
sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_general_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('chuni_static_character_uk', 'chuni_static_character', ['version', 'characterId'], unique=True)
|
||||
op.create_table('chuni_static_map_icon',
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('mapIconId', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('sortName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('iconPath', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True),
|
||||
sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_general_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('chuni_static_mapicon_uk', 'chuni_static_map_icon', ['version', 'mapIconId'], unique=True)
|
||||
op.create_table('chuni_static_nameplate',
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('nameplateId', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('texturePath', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True),
|
||||
sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.Column('sortName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_general_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('chuni_static_nameplate_uk', 'chuni_static_nameplate', ['version', 'nameplateId'], unique=True)
|
||||
op.create_table('chuni_static_trophy',
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('trophyId', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('rareType', mysql.TINYINT(display_width=11), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True),
|
||||
sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_general_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('chuni_static_trophy_uk', 'chuni_static_trophy', ['version', 'trophyId'], unique=True)
|
||||
op.create_table('chuni_static_system_voice',
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('voiceId', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('sortName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('imagePath', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('isEnabled', mysql.TINYINT(display_width=1), server_default=sa.text('1'), autoincrement=False, nullable=True),
|
||||
sa.Column('defaultHave', mysql.TINYINT(display_width=1), server_default=sa.text('0'), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_general_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('chuni_static_systemvoice_uk', 'chuni_static_system_voice', ['version', 'voiceId'], unique=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('chuni_static_systemvoice_uk', table_name='chuni_static_system_voice')
|
||||
op.drop_table('chuni_static_system_voice')
|
||||
op.drop_index('chuni_static_trophy_uk', table_name='chuni_static_trophy')
|
||||
op.drop_table('chuni_static_trophy')
|
||||
op.drop_index('chuni_static_nameplate_uk', table_name='chuni_static_nameplate')
|
||||
op.drop_table('chuni_static_nameplate')
|
||||
op.drop_index('chuni_static_mapicon_uk', table_name='chuni_static_map_icon')
|
||||
op.drop_table('chuni_static_map_icon')
|
||||
op.drop_index('chuni_static_character_uk', table_name='chuni_static_character')
|
||||
op.drop_table('chuni_static_character')
|
||||
|
||||
op.drop_column('chuni_static_avatar', 'defaultHave')
|
||||
op.drop_column('chuni_static_avatar', 'isEnabled')
|
||||
op.drop_column('chuni_static_avatar', 'sortName')
|
||||
# ### end Alembic commands ###
|
@ -1,50 +0,0 @@
|
||||
"""card_add_idm_chip_id
|
||||
|
||||
Revision ID: 48f4acc43a7e
|
||||
Revises: 1e150d16ab6b
|
||||
Create Date: 2024-06-21 23:53:34.369134
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '48f4acc43a7e'
|
||||
down_revision = '1e150d16ab6b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('aime_card', sa.Column('idm', sa.String(length=16), nullable=True))
|
||||
op.add_column('aime_card', sa.Column('chip_id', sa.BIGINT(), nullable=True))
|
||||
op.alter_column('aime_card', 'access_code',
|
||||
existing_type=mysql.VARCHAR(length=20),
|
||||
nullable=False)
|
||||
op.alter_column('aime_card', 'created_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=True)
|
||||
op.create_unique_constraint(None, 'aime_card', ['chip_id'])
|
||||
op.create_unique_constraint(None, 'aime_card', ['idm'])
|
||||
op.create_unique_constraint(None, 'aime_card', ['access_code'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("chip_id", 'aime_card', type_='unique')
|
||||
op.drop_constraint("idm", 'aime_card', type_='unique')
|
||||
op.drop_constraint("access_code", 'aime_card', type_='unique')
|
||||
op.alter_column('aime_card', 'created_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=True)
|
||||
op.alter_column('aime_card', 'access_code',
|
||||
existing_type=mysql.VARCHAR(length=20),
|
||||
nullable=True)
|
||||
op.drop_column('aime_card', 'chip_id')
|
||||
op.drop_column('aime_card', 'idm')
|
||||
# ### end Alembic commands ###
|
@ -1,85 +0,0 @@
|
||||
"""CHUNITHM VERSE support
|
||||
|
||||
Revision ID: 49c295e89cd4
|
||||
Revises: 7070a6fa8cdc
|
||||
Create Date: 2025-03-09 14:10:03.067328
|
||||
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "49c295e89cd4"
|
||||
down_revision = "7070a6fa8cdc"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("chuni_profile_data", sa.Column("trophyIdSub1", sa.Integer()))
|
||||
op.add_column("chuni_profile_data", sa.Column("trophyIdSub2", sa.Integer()))
|
||||
op.add_column("chuni_score_playlog", sa.Column("monthPoint", sa.Integer()))
|
||||
op.add_column("chuni_score_playlog", sa.Column("eventPoint", sa.Integer()))
|
||||
|
||||
op.create_table(
|
||||
"chuni_static_unlock_challenge",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column("unlockChallengeId", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(length=255)),
|
||||
sa.Column("isEnabled", sa.Boolean(), server_default="1"),
|
||||
sa.Column("startDate", sa.TIMESTAMP(), server_default=func.now()),
|
||||
sa.Column("courseId1", sa.Integer()),
|
||||
sa.Column("courseId2", sa.Integer()),
|
||||
sa.Column("courseId3", sa.Integer()),
|
||||
sa.Column("courseId4", sa.Integer()),
|
||||
sa.Column("courseId5", sa.Integer()),
|
||||
sa.UniqueConstraint(
|
||||
"version", "unlockChallengeId", name="chuni_static_unlock_challenge_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"chuni_item_unlock_challenge",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"user",
|
||||
sa.Integer(),
|
||||
sa.ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("unlockChallengeId", sa.Integer(), nullable=False),
|
||||
sa.Column("status", sa.Integer()),
|
||||
sa.Column("clearCourseId", sa.Integer()),
|
||||
sa.Column("conditionType", sa.Integer()),
|
||||
sa.Column("score", sa.Integer()),
|
||||
sa.Column("life", sa.Integer()),
|
||||
sa.Column("clearDate", sa.TIMESTAMP(), server_default=func.now()),
|
||||
sa.UniqueConstraint(
|
||||
"version",
|
||||
"user",
|
||||
"unlockChallengeId",
|
||||
name="chuni_item_unlock_challenge_uk",
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("chuni_score_playlog", "eventPoint")
|
||||
op.drop_column("chuni_score_playlog", "monthPoint")
|
||||
op.drop_column("chuni_profile_data", "trophyIdSub2")
|
||||
op.drop_column("chuni_profile_data", "trophyIdSub1")
|
||||
|
||||
op.drop_table("chuni_static_unlock_challenge")
|
||||
op.drop_table("chuni_item_unlock_challenge")
|
||||
# ### end Alembic commands ###
|
@ -1,48 +0,0 @@
|
||||
"""mai2_add_favs_rivals
|
||||
|
||||
Revision ID: 4a02e623e5e6
|
||||
Revises: 8ad40a6e7be2
|
||||
Create Date: 2024-06-08 19:02:43.856395
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4a02e623e5e6'
|
||||
down_revision = '8ad40a6e7be2'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('mai2_item_favorite_music',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user', sa.Integer(), nullable=False),
|
||||
sa.Column('musicId', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'musicId', name='mai2_item_favorite_music_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('mai2_user_rival',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user', sa.Integer(), nullable=False),
|
||||
sa.Column('rival', sa.Integer(), nullable=False),
|
||||
sa.Column('show', sa.Boolean(), server_default='0', nullable=False),
|
||||
sa.ForeignKeyConstraint(['rival'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'rival', name='mai2_user_rival_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('mai2_user_rival')
|
||||
op.drop_table('mai2_item_favorite_music')
|
||||
# ### end Alembic commands ###
|
@ -1,43 +0,0 @@
|
||||
"""mai2_intimacy
|
||||
|
||||
Revision ID: 54a84103b84e
|
||||
Revises: bc91c1206dca
|
||||
Create Date: 2024-09-16 17:47:49.164546
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import Column, Integer, UniqueConstraint
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '54a84103b84e'
|
||||
down_revision = 'bc91c1206dca'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
"mai2_user_intimate",
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", Integer, nullable=False),
|
||||
Column("partnerId", Integer, nullable=False),
|
||||
Column("intimateLevel", Integer, nullable=False),
|
||||
Column("intimateCountRewarded", Integer, nullable=False),
|
||||
UniqueConstraint("user", "partnerId", name="mai2_user_intimate_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"mai2_user_intimate",
|
||||
"aime_user",
|
||||
["user"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
onupdate="cascade",
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table("mai2_user_intimate")
|
@ -1,53 +0,0 @@
|
||||
"""Mai2 PRiSM support
|
||||
|
||||
Revision ID: 5cf98cfe52ad
|
||||
Revises: 263884e774cc
|
||||
Create Date: 2025-04-08 08:00:51.243089
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
||||
revision = '5cf98cfe52ad'
|
||||
down_revision = '263884e774cc'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('mai2_score_kaleidxscope',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user', sa.Integer(), nullable=False),
|
||||
sa.Column('gateId', sa.Integer(), nullable=True),
|
||||
sa.Column('isGateFound', sa.Boolean(), nullable=True),
|
||||
sa.Column('isKeyFound', sa.Boolean(), nullable=True),
|
||||
sa.Column('isClear', sa.Boolean(), nullable=True),
|
||||
sa.Column('totalRestLife', sa.Integer(), nullable=True),
|
||||
sa.Column('totalAchievement', sa.Integer(), nullable=True),
|
||||
sa.Column('totalDeluxscore', sa.Integer(), nullable=True),
|
||||
sa.Column('bestAchievement', sa.Integer(), nullable=True),
|
||||
sa.Column('bestDeluxscore', sa.Integer(), nullable=True),
|
||||
sa.Column('bestAchievementDate', sa.String(length=25), nullable=True),
|
||||
sa.Column('bestDeluxscoreDate', sa.String(length=25), nullable=True),
|
||||
sa.Column('playCount', sa.Integer(), nullable=True),
|
||||
sa.Column('clearDate', sa.String(length=25), nullable=True),
|
||||
sa.Column('lastPlayDate', sa.String(length=25), nullable=True),
|
||||
sa.Column('isInfoWatched', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'gateId', name='mai2_score_best_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('mai2_playlog', sa.Column('extBool2', sa.Boolean(), nullable=True, server_default=sa.text("NULL")))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('mai2_playlog', 'extBool2')
|
||||
op.drop_table('mai2_score_kaleidxscope')
|
||||
# ### end Alembic commands ###
|
@ -1,41 +0,0 @@
|
||||
"""mai2_presents
|
||||
|
||||
Revision ID: 5ea363686347
|
||||
Revises: 680789dabab3
|
||||
Create Date: 2024-06-28 14:49:07.666879
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5ea363686347'
|
||||
down_revision = '680789dabab3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('mai2_item_present',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('version', sa.INTEGER(), nullable=True),
|
||||
sa.Column('user', sa.Integer(), nullable=True),
|
||||
sa.Column('itemKind', sa.INTEGER(), nullable=False),
|
||||
sa.Column('itemId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('stock', sa.INTEGER(), server_default='1', nullable=False),
|
||||
sa.Column('startDate', sa.TIMESTAMP(), nullable=True),
|
||||
sa.Column('endDate', sa.TIMESTAMP(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('version', 'user', 'itemKind', 'itemId', name='mai2_item_present_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('mai2_item_present')
|
||||
# ### end Alembic commands ###
|
@ -1,28 +0,0 @@
|
||||
"""card_add_memo
|
||||
|
||||
Revision ID: 5ea73f89d982
|
||||
Revises: 745448d83696
|
||||
Create Date: 2024-07-06 22:46:56.992152
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5ea73f89d982'
|
||||
down_revision = '745448d83696'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('aime_card', sa.Column('memo', sa.VARCHAR(length=16), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('aime_card', 'memo')
|
||||
# ### end Alembic commands ###
|
@ -1,295 +0,0 @@
|
||||
"""sao_player_changes
|
||||
|
||||
Revision ID: 680789dabab3
|
||||
Revises: a616fd164e40
|
||||
Create Date: 2024-06-26 23:19:16.863778
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '680789dabab3'
|
||||
down_revision = 'a616fd164e40'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('sao_equipment_data', sa.Column('is_shop_purchase', sa.BOOLEAN(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('is_protect', sa.BOOLEAN(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property1_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property1_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property1_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property2_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property2_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property2_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property3_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property3_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property3_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property4_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property4_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('property4_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_equipment_data', sa.Column('converted_card_num', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.alter_column('sao_equipment_data', 'equipment_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_equipment_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.create_foreign_key(None, 'sao_equipment_data', 'sao_static_property', ['property2_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_equipment_data', 'sao_static_property', ['property4_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_equipment_data', 'sao_static_property', ['property3_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_equipment_data', 'sao_static_property', ['property1_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_equipment_data', 'sao_static_equipment_list', ['equipment_id'], ['EquipmentId'], onupdate='cascade', ondelete='cascade')
|
||||
op.add_column('sao_hero_log_data', sa.Column('max_level_extend_num', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('is_awakenable', sa.BOOLEAN(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('awakening_stage', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('awakening_exp', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('is_shop_purchase', sa.BOOLEAN(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('is_protect', sa.BOOLEAN(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property1_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property1_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property1_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property2_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property2_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property2_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property3_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property3_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property3_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property4_property_id', sa.BIGINT(), server_default='2', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property4_value1', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('property4_value2', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.add_column('sao_hero_log_data', sa.Column('converted_card_num', sa.INTEGER(), server_default='0', nullable=False))
|
||||
op.alter_column('sao_hero_log_data', 'main_weapon',
|
||||
existing_type=mysql.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'sub_equipment',
|
||||
existing_type=mysql.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot1_skill_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot2_skill_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot3_skill_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot4_skill_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot5_skill_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
type_=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('sao_hero_log_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.alter_column("sao_hero_log_data", "user_hero_log_id",
|
||||
existing_type=sa.Integer(),
|
||||
new_column_name="hero_log_id",
|
||||
type_=sa.BIGINT(),
|
||||
nullable=False)
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET skill_slot1_skill_id = NULL WHERE skill_slot1_skill_id = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET skill_slot2_skill_id = NULL WHERE skill_slot2_skill_id = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET skill_slot3_skill_id = NULL WHERE skill_slot3_skill_id = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET skill_slot4_skill_id = NULL WHERE skill_slot4_skill_id = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET skill_slot5_skill_id = NULL WHERE skill_slot5_skill_id = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET main_weapon = NULL WHERE main_weapon = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data SET sub_equipment = NULL WHERE sub_equipment = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_party SET user_hero_log_id_1 = NULL WHERE user_hero_log_id_1 = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_party SET user_hero_log_id_2 = NULL WHERE user_hero_log_id_2 = 0;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_party SET user_hero_log_id_3 = NULL WHERE user_hero_log_id_3 = 0;"))
|
||||
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data INNER JOIN sao_equipment_data ON sao_hero_log_data.main_weapon = sao_equipment_data.equipment_id SET sao_hero_log_data.main_weapon = sao_equipment_data.id;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_log_data INNER JOIN sao_equipment_data ON sao_hero_log_data.sub_equipment = sao_equipment_data.equipment_id SET sao_hero_log_data.sub_equipment = sao_equipment_data.id;"))
|
||||
|
||||
op.execute(sa.text("UPDATE sao_hero_party INNER JOIN sao_hero_log_data ON sao_hero_party.user_hero_log_id_1 = sao_hero_log_data.hero_log_id SET sao_hero_party.user_hero_log_id_1 = sao_hero_log_data.id;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_party INNER JOIN sao_hero_log_data ON sao_hero_party.user_hero_log_id_2 = sao_hero_log_data.hero_log_id SET sao_hero_party.user_hero_log_id_2 = sao_hero_log_data.id;"))
|
||||
op.execute(sa.text("UPDATE sao_hero_party INNER JOIN sao_hero_log_data ON sao_hero_party.user_hero_log_id_3 = sao_hero_log_data.hero_log_id SET sao_hero_party.user_hero_log_id_3 = sao_hero_log_data.id;"))
|
||||
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_property', ['property4_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_skill', ['skill_slot1_skill_id'], ['SkillId'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_skill', ['skill_slot5_skill_id'], ['SkillId'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_skill', ['skill_slot2_skill_id'], ['SkillId'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_skill', ['skill_slot3_skill_id'], ['SkillId'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_equipment_data', ['main_weapon'], ['id'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_property', ['property3_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_skill', ['skill_slot4_skill_id'], ['SkillId'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_equipment_data', ['sub_equipment'], ['id'], onupdate='set null', ondelete='set null')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_property', ['property1_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_hero_list', ['hero_log_id'], ['HeroLogId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_log_data', 'sao_static_property', ['property2_property_id'], ['PropertyId'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_party', 'sao_hero_log_data', ['user_hero_log_id_3'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_party', 'sao_hero_log_data', ['user_hero_log_id_1'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
op.create_foreign_key(None, 'sao_hero_party', 'sao_hero_log_data', ['user_hero_log_id_2'], ['id'], onupdate='cascade', ondelete='cascade')
|
||||
op.alter_column('sao_item_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_play_sessions', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.add_column('sao_player_quest', sa.Column('quest_type', sa.INTEGER(), server_default='1', nullable=False))
|
||||
op.alter_column('sao_player_quest', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_player_quest', 'episode_id',
|
||||
existing_type=mysql.INTEGER(),
|
||||
new_column_name="quest_scene_id",
|
||||
type_=sa.BIGINT(),
|
||||
nullable=False)
|
||||
op.create_foreign_key(None, 'sao_player_quest', 'sao_static_quest', ['quest_scene_id'], ['QuestSceneId'], onupdate='cascade', ondelete='cascade')
|
||||
op.add_column('sao_profile', sa.Column('my_shop', sa.INTEGER(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('fav_hero', sa.INTEGER(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('when_register', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('last_login_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('last_yui_medal_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('last_bonus_yui_medal_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('last_comeback_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('last_login_bonus_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('ad_confirm_date', sa.TIMESTAMP(), nullable=True))
|
||||
op.add_column('sao_profile', sa.Column('login_ct', sa.INTEGER(), server_default='0', nullable=True))
|
||||
op.create_foreign_key(None, 'sao_profile', 'sao_hero_log_data', ['fav_hero'], ['id'], onupdate='cascade', ondelete='set null')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint("sao_profile_ibfk_2", 'sao_profile', type_='foreignkey')
|
||||
op.drop_column('sao_profile', 'login_ct')
|
||||
op.drop_column('sao_profile', 'ad_confirm_date')
|
||||
op.drop_column('sao_profile', 'last_login_bonus_date')
|
||||
op.drop_column('sao_profile', 'last_comeback_date')
|
||||
op.drop_column('sao_profile', 'last_bonus_yui_medal_date')
|
||||
op.drop_column('sao_profile', 'last_yui_medal_date')
|
||||
op.drop_column('sao_profile', 'last_login_date')
|
||||
op.drop_column('sao_profile', 'when_register')
|
||||
op.drop_column('sao_profile', 'fav_hero')
|
||||
op.drop_column('sao_profile', 'my_shop')
|
||||
op.alter_column('sao_player_quest', 'quest_scene_id',
|
||||
existing_type=mysql.BIGINT(),
|
||||
new_column_name="episode_id",
|
||||
type_=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.drop_constraint("sao_player_quest_ibfk_2", 'sao_player_quest', type_='foreignkey')
|
||||
op.alter_column('sao_player_quest', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.drop_column('sao_player_quest', 'quest_scene_id')
|
||||
op.drop_column('sao_player_quest', 'quest_type')
|
||||
op.alter_column('sao_play_sessions', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_item_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.drop_constraint("sao_hero_party_ibfk_2", 'sao_hero_party', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_party_ibfk_3", 'sao_hero_party', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_party_ibfk_4", 'sao_hero_party', type_='foreignkey')
|
||||
op.alter_column("sao_hero_log_data", "hero_log_id",
|
||||
existing_type=sa.BIGINT(),
|
||||
new_column_name="user_hero_log_id",
|
||||
type_=sa.Integer(),
|
||||
nullable=False)
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_2", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_3", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_4", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_5", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_6", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_7", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_8", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_9", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_10", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_11", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_12", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_hero_log_data_ibfk_13", 'sao_hero_log_data', type_='foreignkey')
|
||||
op.alter_column('sao_hero_log_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot5_skill_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot4_skill_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot3_skill_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot2_skill_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'skill_slot1_skill_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'sub_equipment',
|
||||
existing_type=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('sao_hero_log_data', 'main_weapon',
|
||||
existing_type=mysql.INTEGER(),
|
||||
nullable=False)
|
||||
op.drop_column('sao_hero_log_data', 'converted_card_num')
|
||||
op.drop_column('sao_hero_log_data', 'property4_value2')
|
||||
op.drop_column('sao_hero_log_data', 'property4_value1')
|
||||
op.drop_column('sao_hero_log_data', 'property4_property_id')
|
||||
op.drop_column('sao_hero_log_data', 'property3_value2')
|
||||
op.drop_column('sao_hero_log_data', 'property3_value1')
|
||||
op.drop_column('sao_hero_log_data', 'property3_property_id')
|
||||
op.drop_column('sao_hero_log_data', 'property2_value2')
|
||||
op.drop_column('sao_hero_log_data', 'property2_value1')
|
||||
op.drop_column('sao_hero_log_data', 'property2_property_id')
|
||||
op.drop_column('sao_hero_log_data', 'property1_value2')
|
||||
op.drop_column('sao_hero_log_data', 'property1_value1')
|
||||
op.drop_column('sao_hero_log_data', 'property1_property_id')
|
||||
op.drop_column('sao_hero_log_data', 'is_protect')
|
||||
op.drop_column('sao_hero_log_data', 'is_shop_purchase')
|
||||
op.drop_column('sao_hero_log_data', 'awakening_exp')
|
||||
op.drop_column('sao_hero_log_data', 'awakening_stage')
|
||||
op.drop_column('sao_hero_log_data', 'is_awakenable')
|
||||
op.drop_column('sao_hero_log_data', 'max_level_extend_num')
|
||||
op.drop_constraint("sao_equipment_data_ibfk_2", 'sao_equipment_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_equipment_data_ibfk_3", 'sao_equipment_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_equipment_data_ibfk_4", 'sao_equipment_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_equipment_data_ibfk_5", 'sao_equipment_data', type_='foreignkey')
|
||||
op.drop_constraint("sao_equipment_data_ibfk_6", 'sao_equipment_data', type_='foreignkey')
|
||||
op.alter_column('sao_equipment_data', 'get_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.alter_column('sao_equipment_data', 'equipment_id',
|
||||
existing_type=sa.BIGINT(),
|
||||
type_=mysql.INTEGER(),
|
||||
existing_nullable=False)
|
||||
op.drop_column('sao_equipment_data', 'converted_card_num')
|
||||
op.drop_column('sao_equipment_data', 'property4_value2')
|
||||
op.drop_column('sao_equipment_data', 'property4_value1')
|
||||
op.drop_column('sao_equipment_data', 'property4_property_id')
|
||||
op.drop_column('sao_equipment_data', 'property3_value2')
|
||||
op.drop_column('sao_equipment_data', 'property3_value1')
|
||||
op.drop_column('sao_equipment_data', 'property3_property_id')
|
||||
op.drop_column('sao_equipment_data', 'property2_value2')
|
||||
op.drop_column('sao_equipment_data', 'property2_value1')
|
||||
op.drop_column('sao_equipment_data', 'property2_property_id')
|
||||
op.drop_column('sao_equipment_data', 'property1_value2')
|
||||
op.drop_column('sao_equipment_data', 'property1_value1')
|
||||
op.drop_column('sao_equipment_data', 'property1_property_id')
|
||||
op.drop_column('sao_equipment_data', 'is_protect')
|
||||
op.drop_column('sao_equipment_data', 'is_shop_purchase')
|
@ -1,56 +0,0 @@
|
||||
"""GekiChu rating tables
|
||||
|
||||
Revision ID: 6a7e8277763b
|
||||
Revises: d8950c7ce2fc
|
||||
Create Date: 2024-03-13 12:18:53.210018
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import Column, Integer, String
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6a7e8277763b'
|
||||
down_revision = 'd8950c7ce2fc'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
GEKICHU_RATING_TABLE_NAMES = [
|
||||
"chuni_profile_rating",
|
||||
"ongeki_profile_rating",
|
||||
]
|
||||
|
||||
def upgrade():
|
||||
for table_name in GEKICHU_RATING_TABLE_NAMES:
|
||||
op.create_table(
|
||||
table_name,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", Integer, nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("type", String(255), nullable=False),
|
||||
Column("index", Integer, nullable=False),
|
||||
Column("musicId", Integer),
|
||||
Column("difficultId", Integer),
|
||||
Column("romVersionCode", Integer),
|
||||
Column("score", Integer),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
table_name,
|
||||
"aime_user",
|
||||
["user"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
onupdate="cascade",
|
||||
)
|
||||
op.create_unique_constraint(
|
||||
f"{table_name}_uk",
|
||||
table_name,
|
||||
["user", "version", "type", "index"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
for table_name in GEKICHU_RATING_TABLE_NAMES:
|
||||
op.drop_table(table_name)
|
@ -1,42 +0,0 @@
|
||||
"""update_channels
|
||||
|
||||
Revision ID: 7070a6fa8cdc
|
||||
Revises: f6007bbf057d
|
||||
Create Date: 2025-09-27 16:09:55.853051
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7070a6fa8cdc'
|
||||
down_revision = 'f6007bbf057d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('machine_update',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('game', sa.CHAR(length=4), nullable=False),
|
||||
sa.Column('version', sa.VARCHAR(length=15), nullable=False),
|
||||
sa.Column('channel', sa.VARCHAR(length=260), nullable=False),
|
||||
sa.Column('app_ini', sa.VARCHAR(length=260), nullable=True),
|
||||
sa.Column('opt_ini', sa.VARCHAR(length=260), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('game', 'version', 'channel', name='machine_update_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('machine', sa.Column('ota_channel', sa.VARCHAR(length=260), nullable=True))
|
||||
op.drop_column('machine', 'ota_enable')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('machine', sa.Column('ota_enable', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
|
||||
op.drop_column('machine', 'ota_channel')
|
||||
op.drop_table('machine_update')
|
||||
# ### end Alembic commands ###
|
@ -1,28 +0,0 @@
|
||||
"""chuni_team_points
|
||||
|
||||
Revision ID: 745448d83696
|
||||
Revises: 5ea363686347
|
||||
Create Date: 2024-06-29 00:05:22.479187
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '745448d83696'
|
||||
down_revision = '5ea363686347'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('chuni_profile_team', sa.Column('userTeamPoint', sa.JSON(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('chuni_profile_team', 'userTeamPoint')
|
||||
# ### end Alembic commands ###
|
@ -1,28 +0,0 @@
|
||||
"""cxb_add_playlog_grade
|
||||
|
||||
Revision ID: 7dc13e364e53
|
||||
Revises: 2d024cf145a1
|
||||
Create Date: 2024-05-28 22:31:22.264926
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7dc13e364e53'
|
||||
down_revision = '2d024cf145a1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('cxb_playlog', sa.Column('grade', sa.Integer(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('cxb_playlog', 'grade')
|
||||
# ### end Alembic commands ###
|
@ -1,68 +0,0 @@
|
||||
"""mai2_buddies_support
|
||||
|
||||
Revision ID: 81e44dd6047a
|
||||
Revises: 6a7e8277763b
|
||||
Create Date: 2024-03-12 19:10:37.063907
|
||||
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "81e44dd6047a"
|
||||
down_revision = "6a7e8277763b"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
"mai2_playlog_2p",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("user", sa.Integer(), nullable=False),
|
||||
sa.Column("userId1", sa.Integer(), nullable=True),
|
||||
sa.Column("userId2", sa.Integer(), nullable=True),
|
||||
sa.Column("userName1", sa.String(length=25), nullable=True),
|
||||
sa.Column("userName2", sa.String(length=25), nullable=True),
|
||||
sa.Column("regionId", sa.Integer(), nullable=True),
|
||||
sa.Column("placeId", sa.Integer(), nullable=True),
|
||||
sa.Column("user2pPlaylogDetailList", sa.JSON(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user"], ["aime_user.id"], onupdate="cascade", ondelete="cascade"
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"mai2_playlog",
|
||||
sa.Column(
|
||||
"extBool1", sa.Boolean(), nullable=True, server_default=sa.text("NULL")
|
||||
),
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"mai2_profile_detail",
|
||||
sa.Column(
|
||||
"renameCredit", sa.Integer(), nullable=True, server_default=sa.text("NULL")
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"mai2_profile_detail",
|
||||
sa.Column(
|
||||
"currentPlayCount",
|
||||
sa.Integer(),
|
||||
nullable=True,
|
||||
server_default=sa.text("NULL"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table("mai2_playlog_2p")
|
||||
|
||||
op.drop_column("mai2_playlog", "extBool1")
|
||||
op.drop_column("mai2_profile_detail", "renameCredit")
|
||||
op.drop_column("mai2_profile_detail", "currentPlayCount")
|
@ -1,24 +0,0 @@
|
||||
"""Initial Migration
|
||||
|
||||
Revision ID: 835b862f9bf0
|
||||
Revises:
|
||||
Create Date: 2024-01-09 13:06:10.787432
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '835b862f9bf0'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
@ -1,30 +0,0 @@
|
||||
"""ongeki: fix clearStatus
|
||||
|
||||
Revision ID: 8ad40a6e7be2
|
||||
Revises: 7dc13e364e53
|
||||
Create Date: 2024-05-29 19:03:30.062157
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8ad40a6e7be2'
|
||||
down_revision = '7dc13e364e53'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('ongeki_score_best', 'clearStatus',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
type_=sa.Integer(),
|
||||
existing_nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('ongeki_score_best', 'clearStatus',
|
||||
existing_type=sa.Integer(),
|
||||
type_=mysql.TINYINT(display_width=1),
|
||||
existing_nullable=False)
|
@ -1,92 +0,0 @@
|
||||
"""chuni_fix_total_scores
|
||||
|
||||
Revision ID: 91c682918b67
|
||||
Revises: 9c42e54a27fe
|
||||
Create Date: 2025-03-29 11:19:46.063173
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '91c682918b67'
|
||||
down_revision = '9c42e54a27fe'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('chuni_profile_data', 'totalMapNum',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalHiScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalBasicHighScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalExpertHighScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalMasterHighScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalRepertoireCount',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalAdvancedHighScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalUltimaHighScore',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
type_=sa.BigInteger(),
|
||||
existing_nullable=True,
|
||||
existing_server_default=sa.text("'0'"))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('chuni_profile_data', 'totalUltimaHighScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True,
|
||||
existing_server_default=sa.text("'0'"))
|
||||
op.alter_column('chuni_profile_data', 'totalAdvancedHighScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalRepertoireCount',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalMasterHighScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalExpertHighScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalBasicHighScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalHiScore',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
op.alter_column('chuni_profile_data', 'totalMapNum',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=mysql.INTEGER(display_width=11),
|
||||
existing_nullable=True)
|
||||
# ### end Alembic commands ###
|
@ -1,40 +0,0 @@
|
||||
"""remove ongeki_static_music_ranking_list
|
||||
|
||||
Revision ID: 9c42e54a27fe
|
||||
Revises: 41f77ef50588
|
||||
Create Date: 2025-01-06 18:24:16.306748
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9c42e54a27fe'
|
||||
down_revision = '41f77ef50588'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('ongeki_static_music_ranking_uk', table_name='ongeki_static_music_ranking_list')
|
||||
op.drop_table('ongeki_static_music_ranking_list')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('ongeki_static_music_ranking_list',
|
||||
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('version', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('musicId', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('point', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('userName', mysql.VARCHAR(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_0900_ai_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('ongeki_static_music_ranking_uk', 'ongeki_static_music_ranking_list', ['version', 'musicId'], unique=True)
|
||||
# ### end Alembic commands ###
|
@ -1,437 +0,0 @@
|
||||
"""sao_backport
|
||||
|
||||
Revision ID: a616fd164e40
|
||||
Revises: 48f4acc43a7e
|
||||
Create Date: 2024-06-24 20:28:34.471282
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a616fd164e40'
|
||||
down_revision = '48f4acc43a7e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sao_static_quest')
|
||||
op.create_table('sao_static_quest',
|
||||
sa.Column('QuestSceneId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('SortNo', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Tutorial', sa.BOOLEAN(), nullable=False),
|
||||
sa.Column('ColRate', sa.DECIMAL(), nullable=False),
|
||||
sa.Column('LimitDefault', sa.INTEGER(), nullable=False),
|
||||
sa.Column('LimitResurrection', sa.INTEGER(), nullable=False),
|
||||
sa.Column('RewardTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('PlayerTraceTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('SuccessPlayerExp', sa.INTEGER(), nullable=False),
|
||||
sa.Column('FailedPlayerExp', sa.INTEGER(), nullable=False),
|
||||
sa.Column('PairExpRate', sa.INTEGER(), nullable=False),
|
||||
sa.Column('TrioExpRate', sa.INTEGER(), nullable=False),
|
||||
sa.Column('SingleRewardVp', sa.INTEGER(), nullable=False),
|
||||
sa.Column('PairRewardVp', sa.INTEGER(), nullable=False),
|
||||
sa.Column('TrioRewardVp', sa.INTEGER(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('QuestSceneId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
op.create_table('sao_static_property',
|
||||
sa.Column('PropertyId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('PropertyTargetType', sa.INTEGER(), nullable=False),
|
||||
sa.Column('PropertyName', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('PropertyName_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('PropertyNameFormat', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('PropertyNameFormat_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('PropertyTypeId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Value1Min', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Value1Max', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Value2Min', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Value2Max', sa.INTEGER(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('PropertyId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_reward',
|
||||
sa.Column('RewardTableId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('RewardTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('UnanalyzedLogGradeId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardType', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardNum', sa.INTEGER(), nullable=False),
|
||||
sa.Column('StrengthMin', sa.INTEGER(), nullable=False),
|
||||
sa.Column('StrengthMax', sa.INTEGER(), nullable=False),
|
||||
sa.Column('PropertyTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('QuestInfoDisplayFlag', sa.BOOLEAN(), nullable=False),
|
||||
sa.Column('Rate', sa.INTEGER(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('RewardTableId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_skill',
|
||||
sa.Column('SkillId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('WeaponTypeId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Name', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('Name_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('Attack', sa.BOOLEAN(), nullable=False),
|
||||
sa.Column('Passive', sa.BOOLEAN(), nullable=False),
|
||||
sa.Column('Pet', sa.BOOLEAN(), nullable=False),
|
||||
sa.Column('Level', sa.INTEGER(), nullable=False),
|
||||
sa.Column('SkillCondition', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CoolTime', sa.INTEGER(), nullable=False),
|
||||
sa.Column('SkillIcon', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('FriendSkillIcon', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('InfoText', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('InfoText_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('SkillId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_trace_table',
|
||||
sa.Column('PlayerTraceTableId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('PlayerTraceTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardType', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardNum', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Rate', sa.INTEGER(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('PlayerTraceTableId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_player_beginner_mission',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('user', sa.INTEGER(), nullable=False),
|
||||
sa.Column('beginner_mission_id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('condition_id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('is_seat', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.Column('achievement_num', sa.INTEGER(), nullable=False),
|
||||
sa.Column('complete_flag', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.Column('complete_date', sa.TIMESTAMP(), nullable=True),
|
||||
sa.Column('reward_received_flag', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.Column('reward_received_date', sa.TIMESTAMP(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user'),
|
||||
sa.UniqueConstraint('user', 'condition_id', name='sao_player_beginner_mission_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_player_resource_card',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('user', sa.INTEGER(), nullable=False),
|
||||
sa.Column('common_reward_type', sa.INTEGER(), nullable=False),
|
||||
sa.Column('common_reward_id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('holographic_flag', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.Column('serial', sa.VARCHAR(length=20), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('serial'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_player_tutorial',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('user', sa.INTEGER(), nullable=False),
|
||||
sa.Column('tutorial_byte', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'tutorial_byte', name='sao_player_tutorial_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_episode',
|
||||
sa.Column('EpisodeId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('EpisodeChapterId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ReleaseEpisodeId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Title', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('CommentSummary', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('ExBonusTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('QuestSceneId', sa.BIGINT(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['QuestSceneId'], ['sao_static_quest.QuestSceneId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('EpisodeId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_ex_bonus',
|
||||
sa.Column('ExBonusTableId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('ExBonusTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ExBonusConditionId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ConditionValue1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ConditionValue2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardType', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('CommonRewardNum', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Strength', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property1PropertyId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('Property1Value1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property1Value2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property2PropertyId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('Property2Value1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property2Value2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property3PropertyId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('Property3Value1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property3Value2', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property4PropertyId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('Property4Value1', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Property4Value2', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['Property1PropertyId'], ['sao_static_property.PropertyId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['Property2PropertyId'], ['sao_static_property.PropertyId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['Property3PropertyId'], ['sao_static_property.PropertyId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['Property4PropertyId'], ['sao_static_property.PropertyId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('ExBonusTableId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_ex_tower',
|
||||
sa.Column('ExTowerQuestId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('ExTowerId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ReleaseExTowerQuestId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('Title', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('Title_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('ExBonusTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('QuestSceneId', sa.BIGINT(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['QuestSceneId'], ['sao_static_quest.QuestSceneId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('ExTowerQuestId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_side_quest',
|
||||
sa.Column('SideQuestId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('DisplayName', sa.VARCHAR(length=255), nullable=False),
|
||||
sa.Column('DisplayName_en', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('EpisodeNum', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ExBonusTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('QuestSceneId', sa.BIGINT(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['QuestSceneId'], ['sao_static_quest.QuestSceneId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('SideQuestId'),
|
||||
sa.UniqueConstraint('SideQuestId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_skill_table',
|
||||
sa.Column('SkillTableId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('SkillId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('SkillTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('LevelObtained', sa.INTEGER(), nullable=False),
|
||||
sa.Column('AwakeningId', sa.INTEGER(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['SkillId'], ['sao_static_skill.SkillId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('SkillTableId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_static_tower',
|
||||
sa.Column('TowerId', sa.BIGINT(), nullable=False),
|
||||
sa.Column('ReleaseTowerId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('ExBonusTableSubId', sa.INTEGER(), nullable=False),
|
||||
sa.Column('QuestSceneId', sa.BIGINT(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['QuestSceneId'], ['sao_static_quest.QuestSceneId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('TowerId'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_player_ex_bonus',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('user', sa.INTEGER(), nullable=False),
|
||||
sa.Column('quest_scene_id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('ex_bonus_table_id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('quest_clear_flag', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.ForeignKeyConstraint(['ex_bonus_table_id'], ['sao_static_ex_bonus.ExBonusTableId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['quest_scene_id'], ['sao_static_quest.QuestSceneId'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'quest_scene_id', 'ex_bonus_table_id', name='sao_player_ex_bonus_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.create_table('sao_player_hero_card',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('user', sa.INTEGER(), nullable=False),
|
||||
sa.Column('user_hero_id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('holographic_flag', sa.BOOLEAN(), server_default='0', nullable=False),
|
||||
sa.Column('serial', sa.VARCHAR(length=20), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['user_hero_id'], ['sao_hero_log_data.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('serial'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.alter_column('sao_end_sessions', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('now()'),
|
||||
existing_nullable=False)
|
||||
|
||||
op.drop_table('sao_static_equipment_list')
|
||||
op.create_table("sao_static_equipment_list",
|
||||
sa.Column("EquipmentId", sa.BIGINT, primary_key=True, nullable=False),
|
||||
sa.Column("EquipmentType", sa.INTEGER, nullable=False),
|
||||
sa.Column("WeaponTypeId", sa.INTEGER, nullable=False),
|
||||
sa.Column("Name", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("Name_en", sa.VARCHAR(255)),
|
||||
sa.Column("Rarity", sa.INTEGER, nullable=False),
|
||||
sa.Column("Power", sa.INTEGER, nullable=False),
|
||||
sa.Column("StrengthIncrement", sa.INTEGER, nullable=False),
|
||||
sa.Column("SkillCondition", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property1PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property1Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property1Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property2PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property2Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property2Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property3PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property3Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property3Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property4PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property4Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property4Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("SalePrice", sa.INTEGER, nullable=False),
|
||||
sa.Column("CompositionExp", sa.INTEGER, nullable=False),
|
||||
sa.Column("AwakeningExp", sa.INTEGER, nullable=False),
|
||||
sa.Column("FlavorText", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("FlavorText_en", sa.VARCHAR(255)),
|
||||
mysql_charset="utf8mb4"
|
||||
)
|
||||
|
||||
op.drop_table('sao_static_hero_list')
|
||||
op.create_table("sao_static_hero_list",
|
||||
sa.Column("HeroLogId", sa.BIGINT, primary_key=True, nullable=False),
|
||||
sa.Column("CharaId", sa.INTEGER, nullable=False),
|
||||
sa.Column("Name", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("Nickname", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("Name_en", sa.VARCHAR(255)),
|
||||
sa.Column("Nickname_en", sa.VARCHAR(255)),
|
||||
sa.Column("Rarity", sa.INTEGER, nullable=False),
|
||||
sa.Column("WeaponTypeId", sa.INTEGER, nullable=False),
|
||||
sa.Column("HeroLogRoleId", sa.INTEGER, nullable=False),
|
||||
sa.Column("CostumeTypeId", sa.INTEGER, nullable=False),
|
||||
sa.Column("UnitId", sa.INTEGER, nullable=False),
|
||||
sa.Column("DefaultEquipmentId1", sa.BIGINT, sa.ForeignKey("sao_static_equipment_list.EquipmentId", ondelete="cascade", onupdate="cascade")),
|
||||
sa.Column("DefaultEquipmentId2", sa.BIGINT, sa.ForeignKey("sao_static_equipment_list.EquipmentId", ondelete="cascade", onupdate="cascade")),
|
||||
sa.Column("SkillTableSubId", sa.INTEGER, nullable=False),
|
||||
sa.Column("HpMin", sa.INTEGER, nullable=False),
|
||||
sa.Column("HpMax", sa.INTEGER, nullable=False),
|
||||
sa.Column("StrMin", sa.INTEGER, nullable=False),
|
||||
sa.Column("StrMax", sa.INTEGER, nullable=False),
|
||||
sa.Column("VitMin", sa.INTEGER, nullable=False),
|
||||
sa.Column("VitMax", sa.INTEGER, nullable=False),
|
||||
sa.Column("IntMin", sa.INTEGER, nullable=False),
|
||||
sa.Column("IntMax", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property1PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property1Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property1Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property2PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property2Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property2Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property3PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property3Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property3Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property4PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("Property4Value1", sa.INTEGER, nullable=False),
|
||||
sa.Column("Property4Value2", sa.INTEGER, nullable=False),
|
||||
sa.Column("FlavorText", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("FlavorText_en", sa.VARCHAR(255)),
|
||||
sa.Column("SalePrice", sa.INTEGER, nullable=False),
|
||||
sa.Column("CompositionExp", sa.INTEGER, nullable=False),
|
||||
sa.Column("AwakeningExp", sa.INTEGER, nullable=False),
|
||||
sa.Column("Slot4UnlockLevel", sa.INTEGER, nullable=False),
|
||||
sa.Column("Slot5UnlockLevel", sa.INTEGER, nullable=False),
|
||||
sa.Column("CollectionEmptyFrameDisplayFlag", sa.BOOLEAN, nullable=False),
|
||||
mysql_charset="utf8mb4"
|
||||
)
|
||||
|
||||
op.drop_table('sao_static_item_list')
|
||||
op.create_table("sao_static_item_list",
|
||||
sa.Column("ItemId", sa.INTEGER, nullable=False, primary_key=True),
|
||||
sa.Column("ItemTypeId", sa.INTEGER, nullable=False),
|
||||
sa.Column("Name", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("Name_en", sa.VARCHAR(255)),
|
||||
sa.Column("Rarity", sa.INTEGER, nullable=False),
|
||||
sa.Column("Value", sa.INTEGER, nullable=False),
|
||||
sa.Column("PropertyId", sa.BIGINT, sa.ForeignKey("sao_static_property.PropertyId", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
sa.Column("PropertyValue1Min", sa.INTEGER, nullable=False),
|
||||
sa.Column("PropertyValue1Max", sa.INTEGER, nullable=False),
|
||||
sa.Column("PropertyValue2Min", sa.INTEGER, nullable=False),
|
||||
sa.Column("PropertyValue2Max", sa.INTEGER, nullable=False),
|
||||
sa.Column("FlavorText", sa.VARCHAR(255), nullable=False),
|
||||
sa.Column("FlavorText_en", sa.VARCHAR(255)),
|
||||
sa.Column("SalePrice", sa.INTEGER, nullable=False),
|
||||
sa.Column("ItemIcon", sa.VARCHAR(255), nullable=False),
|
||||
mysql_charset="utf8mb4"
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('sao_static_item_list')
|
||||
op.create_table("sao_static_item_list",
|
||||
sa.Column("id", sa.Integer, primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer),
|
||||
sa.Column("itemId", sa.Integer),
|
||||
sa.Column("itemTypeId", sa.Integer),
|
||||
sa.Column("name", sa.String(255)),
|
||||
sa.Column("rarity", sa.Integer),
|
||||
sa.Column("flavorText", sa.String(255)),
|
||||
sa.Column("enabled", sa.Boolean),
|
||||
sa.UniqueConstraint(
|
||||
"version", "itemId", name="sao_static_item_list_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4"
|
||||
)
|
||||
|
||||
op.drop_table('sao_static_hero_list')
|
||||
op.create_table("sao_static_hero_list",
|
||||
sa.Column("id", sa.Integer, primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer),
|
||||
sa.Column("heroLogId", sa.Integer),
|
||||
sa.Column("name", sa.String(255)),
|
||||
sa.Column("nickname", sa.String(255)),
|
||||
sa.Column("rarity", sa.Integer),
|
||||
sa.Column("skillTableSubId", sa.Integer),
|
||||
sa.Column("awakeningExp", sa.Integer),
|
||||
sa.Column("flavorText", sa.String(255)),
|
||||
sa.Column("enabled", sa.Boolean),
|
||||
sa.UniqueConstraint(
|
||||
"version", "heroLogId", name="sao_static_hero_list_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
op.drop_table('sao_static_equipment_list')
|
||||
op.create_table("sao_static_equipment_list",
|
||||
sa.Column("id", sa.Integer, primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer),
|
||||
sa.Column("equipmentId", sa.Integer),
|
||||
sa.Column("equipmentType", sa.Integer),
|
||||
sa.Column("weaponTypeId", sa.Integer),
|
||||
sa.Column("name", sa.String(255)),
|
||||
sa.Column("rarity", sa.Integer),
|
||||
sa.Column("flavorText", sa.String(255)),
|
||||
sa.Column("enabled", sa.Boolean),
|
||||
sa.UniqueConstraint(
|
||||
"version", "equipmentId", name="sao_static_equipment_list_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4"
|
||||
|
||||
)
|
||||
|
||||
op.alter_column('sao_end_sessions', 'play_date',
|
||||
existing_type=mysql.TIMESTAMP(),
|
||||
server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
existing_nullable=False)
|
||||
op.drop_table('sao_player_hero_card')
|
||||
op.drop_table('sao_player_ex_bonus')
|
||||
op.drop_table('sao_static_tower')
|
||||
op.drop_table('sao_static_skill_table')
|
||||
op.drop_table('sao_static_side_quest')
|
||||
op.drop_table('sao_static_ex_tower')
|
||||
op.drop_table('sao_static_ex_bonus')
|
||||
op.drop_table('sao_static_episode')
|
||||
op.drop_table('sao_player_tutorial')
|
||||
op.drop_table('sao_player_resource_card')
|
||||
op.drop_table('sao_player_beginner_mission')
|
||||
op.drop_table('sao_static_trace_table')
|
||||
op.drop_table('sao_static_skill')
|
||||
op.drop_table('sao_static_reward')
|
||||
op.drop_table('sao_static_property')
|
||||
op.drop_table('sao_static_quest')
|
||||
op.create_table('sao_static_quest',
|
||||
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('enabled', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
|
||||
sa.Column('version', mysql.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('questSceneId', mysql.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('sortNo', mysql.INTEGER(), autoincrement=False, nullable=True),
|
||||
sa.Column('name', mysql.VARCHAR(charset='utf8mb4', collation='utf8mb4_general_ci', length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint("version", "questSceneId", name="sao_static_quest_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
@ -1,30 +0,0 @@
|
||||
"""chuni_nameplate_add_opt
|
||||
|
||||
Revision ID: ae364c078429
|
||||
Revises: 5cf98cfe52ad
|
||||
Create Date: 2025-04-08 00:22:22.370660
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ae364c078429'
|
||||
down_revision = '5cf98cfe52ad'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('chuni_static_nameplate', sa.Column('opt', sa.BIGINT(), nullable=True))
|
||||
op.create_foreign_key(None, 'chuni_static_nameplate', 'chuni_static_opt', ['opt'], ['id'], onupdate='cascade', ondelete='SET NULL')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("chuni_static_nameplate_ibfk_1", 'chuni_static_nameplate', type_='foreignkey')
|
||||
op.drop_column('chuni_static_nameplate', 'opt')
|
||||
# ### end Alembic commands ###
|
@ -1,87 +0,0 @@
|
||||
"""CHUNITHM LUMINOUS
|
||||
|
||||
Revision ID: b23f985100ba
|
||||
Revises: 3657efefc5a4
|
||||
Create Date: 2024-06-20 08:08:08.759261
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import Column, Integer, Boolean, UniqueConstraint
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b23f985100ba'
|
||||
down_revision = '3657efefc5a4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
"chuni_profile_net_battle",
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", Integer, nullable=False),
|
||||
Column("isRankUpChallengeFailed", Boolean),
|
||||
Column("highestBattleRankId", Integer),
|
||||
Column("battleIconId", Integer),
|
||||
Column("battleIconNum", Integer),
|
||||
Column("avatarEffectPoint", Integer),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"chuni_profile_net_battle",
|
||||
"aime_user",
|
||||
["user"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
onupdate="cascade",
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"chuni_item_cmission",
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", Integer, nullable=False),
|
||||
Column("missionId", Integer, nullable=False),
|
||||
Column("point", Integer),
|
||||
UniqueConstraint("user", "missionId", name="chuni_item_cmission_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"chuni_item_cmission",
|
||||
"aime_user",
|
||||
["user"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
onupdate="cascade",
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"chuni_item_cmission_progress",
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", Integer, nullable=False),
|
||||
Column("missionId", Integer, nullable=False),
|
||||
Column("order", Integer),
|
||||
Column("stage", Integer),
|
||||
Column("progress", Integer),
|
||||
UniqueConstraint(
|
||||
"user", "missionId", "order", name="chuni_item_cmission_progress_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"chuni_item_cmission_progress",
|
||||
"aime_user",
|
||||
["user"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
onupdate="cascade",
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table("chuni_profile_net_battle")
|
||||
op.drop_table("chuni_item_cmission")
|
||||
op.drop_table("chuni_item_cmission_progress")
|
@ -1,24 +0,0 @@
|
||||
"""mai2_favorite_song_ordering
|
||||
|
||||
Revision ID: bc91c1206dca
|
||||
Revises: 28443e2da5b8
|
||||
Create Date: 2024-09-16 14:24:56.714066
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bc91c1206dca'
|
||||
down_revision = '28443e2da5b8'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('mai2_item_favorite_music', sa.Column('orderId', sa.Integer(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('mai2_item_favorite_music', 'orderId')
|
@ -1,29 +0,0 @@
|
||||
"""Mai2 add PRiSM+ playlog support
|
||||
|
||||
Revision ID: bdf710616ba4
|
||||
Revises: 16f34bf7b968
|
||||
Create Date: 2025-04-02 12:42:08.981516
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bdf710616ba4'
|
||||
|
||||
down_revision = '49c295e89cd4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('mai2_playlog', sa.Column('extBool3', sa.Boolean(), nullable=True,server_default=sa.text("NULL")))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('mai2_playlog', 'extBool3')
|
||||
# ### end Alembic commands ###
|
@ -1,29 +0,0 @@
|
||||
"""Remove old db mgmt system
|
||||
|
||||
Revision ID: d8950c7ce2fc
|
||||
Revises: 835b862f9bf0
|
||||
Create Date: 2024-01-09 13:43:51.381175
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd8950c7ce2fc'
|
||||
down_revision = '835b862f9bf0'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table("schema_versions")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.create_table(
|
||||
"schema_versions",
|
||||
sa.Column("game", sa.String(4), primary_key=True, nullable=False),
|
||||
sa.Column("version", sa.Integer, nullable=False, server_default="1"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
@ -1,38 +0,0 @@
|
||||
"""mai2_add_photos
|
||||
|
||||
Revision ID: d8cd1fa04c2a
|
||||
Revises: 54a84103b84e
|
||||
Create Date: 2024-10-06 03:09:15.959817
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd8cd1fa04c2a'
|
||||
down_revision = '54a84103b84e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('mai2_user_photo',
|
||||
sa.Column('id', sa.VARCHAR(length=36), nullable=False),
|
||||
sa.Column('user', sa.Integer(), nullable=False),
|
||||
sa.Column('playlog_num', sa.INTEGER(), nullable=False),
|
||||
sa.Column('track_num', sa.INTEGER(), nullable=False),
|
||||
sa.Column('when_upload', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user'], ['aime_user.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user', 'playlog_num', 'track_num', name='mai2_user_photo_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('mai2_user_photo')
|
||||
# ### end Alembic commands ###
|
@ -1,50 +0,0 @@
|
||||
"""add_billing_playcount
|
||||
|
||||
Revision ID: f6007bbf057d
|
||||
Revises: 27e3434740df
|
||||
Create Date: 2025-04-19 18:20:35.554137
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f6007bbf057d'
|
||||
down_revision = '27e3434740df'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('machine_billing_playcount',
|
||||
sa.Column('id', sa.BIGINT(), nullable=False),
|
||||
sa.Column('machine', sa.Integer(), nullable=False),
|
||||
sa.Column('game_id', sa.CHAR(length=5), nullable=False),
|
||||
sa.Column('year', sa.INTEGER(), nullable=False),
|
||||
sa.Column('month', sa.INTEGER(), nullable=False),
|
||||
sa.Column('playct', sa.BIGINT(), server_default='1', nullable=False),
|
||||
sa.ForeignKeyConstraint(['machine'], ['machine.id'], onupdate='cascade', ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('machine'),
|
||||
sa.UniqueConstraint('machine', 'game_id', 'year', 'month', name='machine_billing_playcount_uk'),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
op.add_column('machine_billing_credit', sa.Column('game_id', sa.CHAR(length=5), nullable=False))
|
||||
op.drop_constraint("machine_billing_credit_ibfk_1", "machine_billing_credit", "foreignkey")
|
||||
op.drop_index('machine', table_name='machine_billing_credit')
|
||||
op.create_unique_constraint('machine_billing_credit_uk', 'machine_billing_credit', ['machine', 'game_id'])
|
||||
op.create_foreign_key("machine_billing_credit_ibfk_1", "machine_billing_credit", "machine", ["machine"], ["id"], onupdate='cascade', ondelete='cascade')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("machine_billing_credit_ibfk_1", "machine_billing_credit", "foreignkey")
|
||||
op.drop_constraint('machine_billing_credit_uk', 'machine_billing_credit', type_='unique')
|
||||
op.create_index('machine', 'machine_billing_credit', ['machine'], unique=True)
|
||||
op.create_foreign_key("machine_billing_credit_ibfk_1", "machine_billing_credit", "machine", ["machine"], ["id"], onupdate='cascade', ondelete='cascade')
|
||||
op.drop_column('machine_billing_credit', 'game_id')
|
||||
op.drop_table('machine_billing_playcount')
|
||||
# ### end Alembic commands ###
|
@ -17,7 +17,7 @@ except ModuleNotFoundError:
|
||||
|
||||
def cached(lifetime: int = 10, extra_key: Any = None) -> Callable:
|
||||
def _cached(func: Callable) -> Callable:
|
||||
if has_mc and (cfg and cfg.database.enable_memcached):
|
||||
if has_mc:
|
||||
hostname = "127.0.0.1"
|
||||
if cfg:
|
||||
hostname = cfg.database.memcached_host
|
||||
|
@ -1,78 +1,45 @@
|
||||
import logging
|
||||
import os
|
||||
import secrets
|
||||
import string
|
||||
import warnings
|
||||
from hashlib import sha256
|
||||
import logging, coloredlogs
|
||||
from typing import Optional, Dict, List
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy import create_engine
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from typing import ClassVar, Optional
|
||||
|
||||
import alembic.config
|
||||
import importlib, os
|
||||
import secrets, string
|
||||
import bcrypt
|
||||
import coloredlogs
|
||||
import pymysql.err
|
||||
from sqlalchemy.ext.asyncio import (
|
||||
AsyncEngine,
|
||||
AsyncSession,
|
||||
create_async_engine,
|
||||
)
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from hashlib import sha256
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core.data.schema import ArcadeData, BaseData, CardData, UserData, metadata
|
||||
from core.utils import MISSING, Utils
|
||||
from core.data.schema import *
|
||||
from core.utils import Utils
|
||||
|
||||
|
||||
class Data:
|
||||
engine: ClassVar[AsyncEngine] = MISSING
|
||||
session: ClassVar["sessionmaker[AsyncSession]"] = MISSING
|
||||
user: ClassVar[UserData] = MISSING
|
||||
arcade: ClassVar[ArcadeData] = MISSING
|
||||
card: ClassVar[CardData] = MISSING
|
||||
base: ClassVar[BaseData] = MISSING
|
||||
|
||||
def __init__(self, cfg: CoreConfig) -> None:
|
||||
self.config = cfg
|
||||
|
||||
if self.config.database.sha2_password:
|
||||
passwd = sha256(self.config.database.password.encode()).digest()
|
||||
self.__url = f"{self.config.database.protocol}+aiomysql://{self.config.database.username}:{passwd.hex()}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}"
|
||||
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{passwd.hex()}@{self.config.database.host}/{self.config.database.name}?charset=utf8mb4"
|
||||
else:
|
||||
self.__url = f"{self.config.database.protocol}+aiomysql://{self.config.database.username}:{self.config.database.password}@{self.config.database.host}:{self.config.database.port}/{self.config.database.name}"
|
||||
self.__url = f"{self.config.database.protocol}://{self.config.database.username}:{self.config.database.password}@{self.config.database.host}/{self.config.database.name}?charset=utf8mb4"
|
||||
|
||||
if Data.engine is MISSING:
|
||||
Data.engine = create_async_engine(
|
||||
self.__url,
|
||||
pool_recycle=3600,
|
||||
isolation_level="AUTOCOMMIT",
|
||||
connect_args={
|
||||
"charset": "utf8mb4",
|
||||
"ssl": self.config.database.create_ssl_context_if_enabled(),
|
||||
},
|
||||
)
|
||||
self.__engine = Data.engine
|
||||
self.__engine = create_engine(self.__url, pool_recycle=3600)
|
||||
session = sessionmaker(bind=self.__engine, autoflush=True, autocommit=True)
|
||||
self.session = scoped_session(session)
|
||||
|
||||
if Data.session is MISSING:
|
||||
Data.session = sessionmaker(Data.engine, expire_on_commit=False, class_=AsyncSession)
|
||||
|
||||
if Data.user is MISSING:
|
||||
Data.user = UserData(self.config, self.session)
|
||||
|
||||
if Data.arcade is MISSING:
|
||||
Data.arcade = ArcadeData(self.config, self.session)
|
||||
|
||||
if Data.card is MISSING:
|
||||
Data.card = CardData(self.config, self.session)
|
||||
|
||||
if Data.base is MISSING:
|
||||
Data.base = BaseData(self.config, self.session)
|
||||
self.user = UserData(self.config, self.session)
|
||||
self.arcade = ArcadeData(self.config, self.session)
|
||||
self.card = CardData(self.config, self.session)
|
||||
self.base = BaseData(self.config, self.session)
|
||||
self.current_schema_version = 4
|
||||
|
||||
log_fmt_str = "[%(asctime)s] %(levelname)s | Database | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
self.logger = logging.getLogger("database")
|
||||
|
||||
# Prevent the logger from adding handlers multiple times
|
||||
if not getattr(self.logger, "handler_set", None):
|
||||
log_fmt_str = "[%(asctime)s] %(levelname)s | Database | %(message)s"
|
||||
log_fmt = logging.Formatter(log_fmt_str)
|
||||
if not getattr(self.logger, "handler_set", None):
|
||||
fileHandler = TimedRotatingFileHandler(
|
||||
"{0}/{1}.log".format(self.config.server.log_dir, "db"),
|
||||
encoding="utf-8",
|
||||
@ -93,210 +60,276 @@ class Data:
|
||||
)
|
||||
self.logger.handler_set = True # type: ignore
|
||||
|
||||
def __alembic_cmd(self, command: str, *args: str) -> None:
|
||||
old_dir = os.path.abspath(os.path.curdir)
|
||||
base_dir = os.path.join(os.path.abspath(os.path.curdir), 'core', 'data', 'alembic')
|
||||
alembicArgs = [
|
||||
"-c",
|
||||
os.path.join(base_dir, "alembic.ini"),
|
||||
"-x",
|
||||
f"script_location={base_dir}",
|
||||
"-x",
|
||||
f"sqlalchemy.url={self.__url}",
|
||||
command,
|
||||
]
|
||||
alembicArgs.extend(args)
|
||||
os.chdir(base_dir)
|
||||
alembic.config.main(argv=alembicArgs)
|
||||
os.chdir(old_dir)
|
||||
|
||||
async def create_database(self):
|
||||
def create_database(self):
|
||||
self.logger.info("Creating databases...")
|
||||
try:
|
||||
metadata.create_all(self.__engine.connect())
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"Failed to create databases! {e}")
|
||||
return
|
||||
|
||||
with warnings.catch_warnings():
|
||||
# SQLAlchemy will generate a nice primary key constraint name, but in
|
||||
# MySQL/MariaDB the constraint name is always PRIMARY. Every time a
|
||||
# custom primary key name is generated, a warning is emitted from pymysql,
|
||||
# which we don't care about. Other warnings may be helpful though, don't
|
||||
# suppress everything.
|
||||
warnings.filterwarnings(
|
||||
action="ignore",
|
||||
message=r"Name '(.+)' ignored for PRIMARY key\.",
|
||||
category=pymysql.err.Warning,
|
||||
games = Utils.get_all_titles()
|
||||
for game_dir, game_mod in games.items():
|
||||
try:
|
||||
if hasattr(game_mod, "database") and hasattr(
|
||||
game_mod, "current_schema_version"
|
||||
):
|
||||
game_mod.database(self.config)
|
||||
metadata.create_all(self.__engine.connect())
|
||||
|
||||
self.base.set_schema_ver(
|
||||
game_mod.current_schema_version, game_mod.game_codes[0]
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.logger.warning(
|
||||
f"Could not load database schema from {game_dir} - {e}"
|
||||
)
|
||||
|
||||
self.logger.info(f"Setting base_schema_ver to {self.current_schema_version}")
|
||||
self.base.set_schema_ver(self.current_schema_version)
|
||||
|
||||
self.logger.info(
|
||||
f"Setting user auto_incrememnt to {self.config.database.user_table_autoincrement_start}"
|
||||
)
|
||||
self.user.reset_autoincrement(
|
||||
self.config.database.user_table_autoincrement_start
|
||||
)
|
||||
|
||||
def recreate_database(self):
|
||||
self.logger.info("Dropping all databases...")
|
||||
self.base.execute("SET FOREIGN_KEY_CHECKS=0")
|
||||
try:
|
||||
metadata.drop_all(self.__engine.connect())
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"Failed to drop databases! {e}")
|
||||
return
|
||||
|
||||
for root, dirs, files in os.walk("./titles"):
|
||||
for dir in dirs:
|
||||
if not dir.startswith("__"):
|
||||
try:
|
||||
mod = importlib.import_module(f"titles.{dir}")
|
||||
|
||||
try:
|
||||
if hasattr(mod, "database"):
|
||||
mod.database(self.config)
|
||||
metadata.drop_all(self.__engine.connect())
|
||||
|
||||
except Exception as e:
|
||||
self.logger.warning(
|
||||
f"Could not load database schema from {dir} - {e}"
|
||||
)
|
||||
|
||||
except ImportError as e:
|
||||
self.logger.warning(
|
||||
f"Failed to load database schema dir {dir} - {e}"
|
||||
)
|
||||
break
|
||||
|
||||
self.base.execute("SET FOREIGN_KEY_CHECKS=1")
|
||||
|
||||
self.create_database()
|
||||
|
||||
def migrate_database(self, game: str, version: Optional[int], action: str) -> None:
|
||||
old_ver = self.base.get_schema_ver(game)
|
||||
sql = ""
|
||||
if version is None:
|
||||
if not game == "CORE":
|
||||
titles = Utils.get_all_titles()
|
||||
|
||||
for folder, mod in titles.items():
|
||||
if not mod.game_codes[0] == game:
|
||||
continue
|
||||
|
||||
if hasattr(mod, "current_schema_version"):
|
||||
version = mod.current_schema_version
|
||||
|
||||
else:
|
||||
self.logger.warn(
|
||||
f"current_schema_version not found for {folder}"
|
||||
)
|
||||
|
||||
else:
|
||||
version = self.current_schema_version
|
||||
|
||||
if version is None:
|
||||
self.logger.warn(
|
||||
f"Could not determine latest version for {game}, please specify --version"
|
||||
)
|
||||
|
||||
async with self.engine.begin() as conn:
|
||||
await conn.run_sync(metadata.create_all, checkfirst=True)
|
||||
|
||||
for _, mod in Utils.get_all_titles().items():
|
||||
if hasattr(mod, "database"):
|
||||
mod.database(self.config)
|
||||
|
||||
await conn.run_sync(metadata.create_all, checkfirst=True)
|
||||
|
||||
# Stamp the end revision as if alembic had created it, so it can take off after this.
|
||||
self.__alembic_cmd(
|
||||
"stamp",
|
||||
"head",
|
||||
if old_ver is None:
|
||||
self.logger.error(
|
||||
f"Schema for game {game} does not exist, did you run the creation script?"
|
||||
)
|
||||
return
|
||||
|
||||
def schema_upgrade(self, ver: Optional[str] = None):
|
||||
with warnings.catch_warnings():
|
||||
# SQLAlchemy will generate a nice primary key constraint name, but in
|
||||
# MySQL/MariaDB the constraint name is always PRIMARY. Every time a
|
||||
# custom primary key name is generated, a warning is emitted from pymysql,
|
||||
# which we don't care about. Other warnings may be helpful though, don't
|
||||
# suppress everything.
|
||||
warnings.filterwarnings(
|
||||
action="ignore",
|
||||
message=r"Name '(.+)' ignored for PRIMARY key\.",
|
||||
category=pymysql.err.Warning,
|
||||
if old_ver == version:
|
||||
self.logger.info(
|
||||
f"Schema for game {game} is already version {old_ver}, nothing to do"
|
||||
)
|
||||
return
|
||||
|
||||
self.__alembic_cmd(
|
||||
"upgrade",
|
||||
"head" if not ver else ver,
|
||||
)
|
||||
if action == "upgrade":
|
||||
for x in range(old_ver, version):
|
||||
if not os.path.exists(
|
||||
f"core/data/schema/versions/{game.upper()}_{x + 1}_{action}.sql"
|
||||
):
|
||||
self.logger.error(
|
||||
f"Could not find {action} script {game.upper()}_{x + 1}_{action}.sql in core/data/schema/versions folder"
|
||||
)
|
||||
return
|
||||
|
||||
def schema_downgrade(self, ver: str):
|
||||
with warnings.catch_warnings():
|
||||
# SQLAlchemy will generate a nice primary key constraint name, but in
|
||||
# MySQL/MariaDB the constraint name is always PRIMARY. Every time a
|
||||
# custom primary key name is generated, a warning is emitted from pymysql,
|
||||
# which we don't care about. Other warnings may be helpful though, don't
|
||||
# suppress everything.
|
||||
warnings.filterwarnings(
|
||||
action="ignore",
|
||||
message=r"Name '(.+)' ignored for PRIMARY key\.",
|
||||
category=pymysql.err.Warning,
|
||||
)
|
||||
with open(
|
||||
f"core/data/schema/versions/{game.upper()}_{x + 1}_{action}.sql",
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
sql = f.read()
|
||||
|
||||
self.__alembic_cmd(
|
||||
"downgrade",
|
||||
ver,
|
||||
)
|
||||
result = self.base.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error("Error execuing sql script!")
|
||||
return None
|
||||
|
||||
async def create_owner(self, email: Optional[str] = None, code: str = "00000000000000000000") -> None:
|
||||
else:
|
||||
for x in range(old_ver, version, -1):
|
||||
if not os.path.exists(
|
||||
f"core/data/schema/versions/{game.upper()}_{x - 1}_{action}.sql"
|
||||
):
|
||||
self.logger.error(
|
||||
f"Could not find {action} script {game.upper()}_{x - 1}_{action}.sql in core/data/schema/versions folder"
|
||||
)
|
||||
return
|
||||
|
||||
with open(
|
||||
f"core/data/schema/versions/{game.upper()}_{x - 1}_{action}.sql",
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
sql = f.read()
|
||||
|
||||
result = self.base.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error("Error execuing sql script!")
|
||||
return None
|
||||
|
||||
result = self.base.set_schema_ver(version, game)
|
||||
if result is None:
|
||||
self.logger.error("Error setting version in schema_version table!")
|
||||
return None
|
||||
|
||||
self.logger.info(f"Successfully migrated {game} to schema version {version}")
|
||||
|
||||
def create_owner(self, email: Optional[str] = None) -> None:
|
||||
pw = "".join(
|
||||
secrets.choice(string.ascii_letters + string.digits) for i in range(20)
|
||||
)
|
||||
hash = bcrypt.hashpw(pw.encode(), bcrypt.gensalt())
|
||||
|
||||
user_id = await self.user.create_user(username="sysowner", email=email, password=hash.decode(), permission=255)
|
||||
user_id = self.user.create_user(email=email, permission=255, password=hash)
|
||||
if user_id is None:
|
||||
self.logger.error(f"Failed to create owner with email {email}")
|
||||
return
|
||||
|
||||
card_id = await self.card.create_card(user_id, code)
|
||||
card_id = self.card.create_card(user_id, "00000000000000000000")
|
||||
if card_id is None:
|
||||
self.logger.error(f"Failed to create card for owner with id {user_id}")
|
||||
return
|
||||
|
||||
self.logger.warning(
|
||||
f"Successfully created owner with email {email}, access code {code}, and password {pw} Make sure to change this password and assign a real card ASAP!"
|
||||
self.logger.warn(
|
||||
f"Successfully created owner with email {email}, access code 00000000000000000000, and password {pw} Make sure to change this password and assign a real card ASAP!"
|
||||
)
|
||||
|
||||
async def migrate(self) -> None:
|
||||
exist = await self.base.execute("SELECT * FROM alembic_version")
|
||||
if exist is not None:
|
||||
self.logger.warning("No need to migrate as you have already migrated to alembic. If you are trying to upgrade the schema, use `upgrade` instead!")
|
||||
|
||||
def migrate_card(self, old_ac: str, new_ac: str, should_force: bool) -> None:
|
||||
if old_ac == new_ac:
|
||||
self.logger.error("Both access codes are the same!")
|
||||
return
|
||||
|
||||
self.logger.info("Upgrading to latest with legacy system")
|
||||
if not await self.legacy_upgrade():
|
||||
self.logger.warning("No need to migrate as you have already deleted the old schema_versions system. If you are trying to upgrade the schema, use `upgrade` instead!")
|
||||
|
||||
new_card = self.card.get_card_by_access_code(new_ac)
|
||||
if new_card is None:
|
||||
self.card.update_access_code(old_ac, new_ac)
|
||||
return
|
||||
self.logger.info("Done")
|
||||
|
||||
self.logger.info("Stamp with initial revision")
|
||||
self.__alembic_cmd(
|
||||
"stamp",
|
||||
"835b862f9bf0",
|
||||
)
|
||||
|
||||
self.logger.info("Upgrade")
|
||||
self.__alembic_cmd(
|
||||
"upgrade",
|
||||
"head",
|
||||
)
|
||||
|
||||
async def legacy_upgrade(self) -> bool:
|
||||
vers = await self.base.execute("SELECT * FROM schema_versions")
|
||||
if vers is None:
|
||||
self.logger.warning("Cannot legacy upgrade, schema_versions table unavailable!")
|
||||
return False
|
||||
|
||||
db_vers = {}
|
||||
vers_list = vers.fetchall()
|
||||
for x in vers_list:
|
||||
db_vers[x['game']] = x['version']
|
||||
|
||||
core_now_ver = int(db_vers['CORE']) + 1
|
||||
while os.path.exists(f"core/data/schema/versions/CORE_{core_now_ver}_upgrade.sql"):
|
||||
with open(f"core/data/schema/versions/CORE_{core_now_ver}_upgrade.sql", "r") as f:
|
||||
result = await self.base.execute(f.read())
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Invalid upgrade script CORE_{core_now_ver}_upgrade.sql")
|
||||
break
|
||||
|
||||
result = await self.base.execute(f"UPDATE schema_versions SET version = {core_now_ver} WHERE game = 'CORE'")
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update schema version for CORE to {core_now_ver}")
|
||||
break
|
||||
|
||||
self.logger.info(f"Upgrade CORE to version {core_now_ver}")
|
||||
core_now_ver += 1
|
||||
|
||||
for _, mod in Utils.get_all_titles().items():
|
||||
game_codes = getattr(mod, "game_codes", [])
|
||||
for game in game_codes:
|
||||
if game not in db_vers:
|
||||
self.logger.warning(f"{game} does not have an antry in schema_versions, skipping")
|
||||
continue
|
||||
|
||||
now_ver = int(db_vers[game]) + 1
|
||||
while os.path.exists(f"core/data/schema/versions/{game}_{now_ver}_upgrade.sql"):
|
||||
with open(f"core/data/schema/versions/{game}_{now_ver}_upgrade.sql", "r") as f:
|
||||
result = await self.base.execute(f.read())
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Invalid upgrade script {game}_{now_ver}_upgrade.sql")
|
||||
break
|
||||
|
||||
result = await self.base.execute(f"UPDATE schema_versions SET version = {now_ver} WHERE game = '{game}'")
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update schema version for {game} to {now_ver}")
|
||||
break
|
||||
|
||||
self.logger.info(f"Upgrade {game} to version {now_ver}")
|
||||
now_ver += 1
|
||||
|
||||
return True
|
||||
|
||||
async def create_revision(self, message: str) -> None:
|
||||
if not message:
|
||||
self.logger.info("Message is required for create-revision")
|
||||
if not should_force:
|
||||
self.logger.warn(
|
||||
f"Card already exists for access code {new_ac} (id {new_card['id']}). If you wish to continue, rerun with the '--force' flag."
|
||||
f" All exiting data on the target card {new_ac} will be perminently erased and replaced with data from card {old_ac}."
|
||||
)
|
||||
return
|
||||
|
||||
self.__alembic_cmd(
|
||||
"revision",
|
||||
"-m",
|
||||
message,
|
||||
)
|
||||
|
||||
async def create_revision_auto(self, message: str) -> None:
|
||||
if not message:
|
||||
self.logger.info("Message is required for create-revision")
|
||||
return
|
||||
|
||||
for _, mod in Utils.get_all_titles().items():
|
||||
if hasattr(mod, "database"):
|
||||
mod.database(self.config)
|
||||
|
||||
self.__alembic_cmd(
|
||||
"revision",
|
||||
"--autogenerate",
|
||||
"-m",
|
||||
message,
|
||||
self.logger.info(
|
||||
f"All exiting data on the target card {new_ac} will be perminently erased and replaced with data from card {old_ac}."
|
||||
)
|
||||
self.card.delete_card(new_card["id"])
|
||||
self.card.update_access_code(old_ac, new_ac)
|
||||
|
||||
hanging_user = self.user.get_user(new_card["user"])
|
||||
if hanging_user["password"] is None:
|
||||
self.logger.info(f"Delete hanging user {hanging_user['id']}")
|
||||
self.user.delete_user(hanging_user["id"])
|
||||
|
||||
def delete_hanging_users(self) -> None:
|
||||
"""
|
||||
Finds and deletes users that have not registered for the webui that have no cards assocated with them.
|
||||
"""
|
||||
unreg_users = self.user.get_unregistered_users()
|
||||
if unreg_users is None:
|
||||
self.logger.error("Error occoured finding unregistered users")
|
||||
|
||||
for user in unreg_users:
|
||||
cards = self.card.get_user_cards(user["id"])
|
||||
if cards is None:
|
||||
self.logger.error(f"Error getting cards for user {user['id']}")
|
||||
continue
|
||||
|
||||
if not cards:
|
||||
self.logger.info(f"Delete hanging user {user['id']}")
|
||||
self.user.delete_user(user["id"])
|
||||
|
||||
def autoupgrade(self) -> None:
|
||||
all_game_versions = self.base.get_all_schema_vers()
|
||||
if all_game_versions is None:
|
||||
self.logger.warn("Failed to get schema versions")
|
||||
return
|
||||
|
||||
all_games = Utils.get_all_titles()
|
||||
all_games_list: Dict[str, int] = {}
|
||||
for _, mod in all_games.items():
|
||||
if hasattr(mod, "current_schema_version"):
|
||||
all_games_list[mod.game_codes[0]] = mod.current_schema_version
|
||||
|
||||
for x in all_game_versions:
|
||||
failed = False
|
||||
game = x["game"].upper()
|
||||
update_ver = int(x["version"])
|
||||
latest_ver = all_games_list.get(game, 1)
|
||||
if game == "CORE":
|
||||
latest_ver = self.current_schema_version
|
||||
|
||||
if update_ver == latest_ver:
|
||||
self.logger.info(f"{game} is already latest version")
|
||||
continue
|
||||
|
||||
for y in range(update_ver + 1, latest_ver + 1):
|
||||
if os.path.exists(f"core/data/schema/versions/{game}_{y}_upgrade.sql"):
|
||||
with open(
|
||||
f"core/data/schema/versions/{game}_{y}_upgrade.sql",
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
sql = f.read()
|
||||
|
||||
result = self.base.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"Error execuing sql script for game {game} v{y}!"
|
||||
)
|
||||
failed = True
|
||||
break
|
||||
else:
|
||||
self.logger.warning(f"Could not find script {game}_{y}_upgrade.sql")
|
||||
failed = True
|
||||
|
||||
if not failed:
|
||||
self.base.set_schema_ver(latest_ver, game)
|
||||
|
@ -1,17 +1,15 @@
|
||||
import re
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, Table, and_, or_, UniqueConstraint
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.sql import func, select
|
||||
from typing import Optional, Dict
|
||||
from sqlalchemy import Table, Column
|
||||
from sqlalchemy.sql.schema import ForeignKey, PrimaryKeyConstraint
|
||||
from sqlalchemy.types import JSON, Boolean, Integer, String, BIGINT, INTEGER, CHAR, FLOAT, VARCHAR
|
||||
from sqlalchemy.types import Integer, String, Boolean
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
import re
|
||||
|
||||
from core.data.schema.base import BaseData, metadata
|
||||
from core.const import *
|
||||
|
||||
arcade: Table = Table(
|
||||
arcade = Table(
|
||||
"arcade",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
@ -23,11 +21,10 @@ arcade: Table = Table(
|
||||
Column("city", String(255)),
|
||||
Column("region_id", Integer),
|
||||
Column("timezone", String(255)),
|
||||
Column("ip", String(39)),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
machine: Table = Table(
|
||||
machine = Table(
|
||||
"machine",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
@ -41,27 +38,12 @@ machine: Table = Table(
|
||||
Column("game", String(4)),
|
||||
Column("country", String(3)), # overwrites if not null
|
||||
Column("timezone", String(255)),
|
||||
Column("memo", String(255)),
|
||||
Column("ota_enable", Boolean),
|
||||
Column("is_cab", Boolean),
|
||||
Column("ota_channel", VARCHAR(260)),
|
||||
Column("data", JSON),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
update: Table = Table(
|
||||
"machine_update",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("game", CHAR(4), nullable=False),
|
||||
Column("version", VARCHAR(15), nullable=False),
|
||||
Column("channel", VARCHAR(260), nullable=False),
|
||||
Column("app_ini", VARCHAR(260)),
|
||||
Column("opt_ini", VARCHAR(260)),
|
||||
UniqueConstraint("game", "version", "channel", name="machine_update_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
arcade_owner: Table = Table(
|
||||
arcade_owner = Table(
|
||||
"arcade_owner",
|
||||
metadata,
|
||||
Column(
|
||||
@ -81,79 +63,9 @@ arcade_owner: Table = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
billing_charge: Table = Table(
|
||||
"machine_billing_charge",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("game_ver", FLOAT, nullable=False),
|
||||
Column("play_count", INTEGER, nullable=False),
|
||||
Column("play_limit", INTEGER, nullable=False),
|
||||
Column("product_code", INTEGER, nullable=False),
|
||||
Column("product_count", INTEGER, nullable=False),
|
||||
Column("func_type", INTEGER, nullable=False),
|
||||
Column("player_number", INTEGER, nullable=False),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
# These settings are only really of interest
|
||||
# for real cabinets operating as pay-to-play
|
||||
billing_credit: Table = Table(
|
||||
"machine_billing_credit",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("chute_type", INTEGER, nullable=False),
|
||||
Column("service_type", INTEGER, nullable=False),
|
||||
Column("operation_type", INTEGER, nullable=False),
|
||||
Column("coin_rate0", INTEGER, nullable=False),
|
||||
Column("coin_rate1", INTEGER, nullable=False),
|
||||
Column("coin_bonus", INTEGER, nullable=False),
|
||||
Column("credit_rate", INTEGER, nullable=False),
|
||||
Column("coin_count_slot0", INTEGER, nullable=False),
|
||||
Column("coin_count_slot1", INTEGER, nullable=False),
|
||||
Column("coin_count_slot2", INTEGER, nullable=False),
|
||||
Column("coin_count_slot3", INTEGER, nullable=False),
|
||||
Column("coin_count_slot4", INTEGER, nullable=False),
|
||||
Column("coin_count_slot5", INTEGER, nullable=False),
|
||||
Column("coin_count_slot6", INTEGER, nullable=False),
|
||||
Column("coin_count_slot7", INTEGER, nullable=False),
|
||||
UniqueConstraint("machine", "game_id", name="machine_billing_credit_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
billing_playct: Table = Table(
|
||||
"machine_billing_playcount",
|
||||
metadata,
|
||||
Column("id", BIGINT, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"machine",
|
||||
Integer,
|
||||
ForeignKey("machine.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False, unique=True
|
||||
),
|
||||
Column("game_id", CHAR(5), nullable=False),
|
||||
Column("year", INTEGER, nullable=False),
|
||||
Column("month", INTEGER, nullable=False),
|
||||
Column("playct", BIGINT, nullable=False, server_default="1"),
|
||||
UniqueConstraint("machine", "game_id", "year", "month", name="machine_billing_playcount_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
class ArcadeData(BaseData):
|
||||
async def get_machine(self, serial: Optional[str] = None, id: Optional[int] = None) -> Optional[Row]:
|
||||
def get_machine(self, serial: str = None, id: int = None) -> Optional[Dict]:
|
||||
if serial is not None:
|
||||
serial = serial.replace("-", "")
|
||||
if len(serial) == 11:
|
||||
@ -173,43 +85,34 @@ class ArcadeData(BaseData):
|
||||
self.logger.error(f"{__name__ }: Need either serial or ID to look up!")
|
||||
return None
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
async def create_machine(
|
||||
def put_machine(
|
||||
self,
|
||||
arcade_id: int,
|
||||
serial: str = "",
|
||||
board: Optional[str] = None,
|
||||
game: Optional[str] = None,
|
||||
board: str = None,
|
||||
game: str = None,
|
||||
is_cab: bool = False,
|
||||
) -> Optional[int]:
|
||||
if not arcade_id:
|
||||
if arcade_id:
|
||||
self.logger.error(f"{__name__ }: Need arcade id!")
|
||||
return None
|
||||
|
||||
sql = machine.insert().values(
|
||||
arcade=arcade_id, serial=serial, board=board, game=game, is_cab=is_cab
|
||||
arcade=arcade_id, keychip=serial, board=board, game=game, is_cab=is_cab
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def set_machine_arcade(self, machine_id: int, new_arcade: int) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(arcade = new_arcade)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} arcade to {new_arcade}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_serial(self, machine_id: int, serial: str) -> None:
|
||||
result = await self.execute(
|
||||
def set_machine_serial(self, machine_id: int, serial: str) -> None:
|
||||
result = self.execute(
|
||||
machine.update(machine.c.id == machine_id).values(keychip=serial)
|
||||
)
|
||||
if result is None:
|
||||
@ -218,8 +121,8 @@ class ArcadeData(BaseData):
|
||||
)
|
||||
return result.lastrowid
|
||||
|
||||
async def set_machine_boardid(self, machine_id: int, boardid: str) -> None:
|
||||
result = await self.execute(
|
||||
def set_machine_boardid(self, machine_id: int, boardid: str) -> None:
|
||||
result = self.execute(
|
||||
machine.update(machine.c.id == machine_id).values(board=boardid)
|
||||
)
|
||||
if result is None:
|
||||
@ -227,83 +130,22 @@ class ArcadeData(BaseData):
|
||||
f"Failed to update board id for machine {machine_id} -> {boardid}"
|
||||
)
|
||||
|
||||
async def set_machine_game(self, machine_id: int, new_game: Optional[str]) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(game = new_game)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} game to {new_game}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_country(self, machine_id: int, new_country: Optional[str]) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(country = new_country)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} country to {new_country}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_timezone(self, machine_id: int, new_timezone: Optional[str]) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(timezone = new_timezone)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} timezone to {new_timezone}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_real_cabinet(self, machine_id: int, is_real: bool = False) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(is_cab = is_real)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} is_cab to {is_real}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_ota_channel(self, machine_id: int, channel_name: Optional[str] = None) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(ota_channel = channel_name)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} ota channel to {channel_name}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_machine_memo(self, machine_id: int, new_memo: Optional[str]) -> bool:
|
||||
sql = machine.update(machine.c.id == machine_id).values(memo = new_memo)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update machine {machine_id} memo")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def get_arcade(self, id: int) -> Optional[Row]:
|
||||
def get_arcade(self, id: int) -> Optional[Dict]:
|
||||
sql = arcade.select(arcade.c.id == id)
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
async def get_arcade_machines(self, id: int) -> Optional[List[Row]]:
|
||||
sql = machine.select(machine.c.arcade == id)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def create_arcade(
|
||||
def put_arcade(
|
||||
self,
|
||||
name: Optional[str] = None,
|
||||
nickname: Optional[str] = None,
|
||||
name: str,
|
||||
nickname: str = None,
|
||||
country: str = "JPN",
|
||||
country_id: int = 1,
|
||||
state: str = "",
|
||||
city: str = "",
|
||||
region_id: int = 1,
|
||||
regional_id: int = 1,
|
||||
) -> Optional[int]:
|
||||
if nickname is None:
|
||||
nickname = name
|
||||
@ -315,296 +157,63 @@ class ArcadeData(BaseData):
|
||||
country_id=country_id,
|
||||
state=state,
|
||||
city=city,
|
||||
region_id=region_id,
|
||||
regional_id=regional_id,
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def get_arcades_managed_by_user(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = select(arcade).join(arcade_owner, arcade_owner.c.arcade == arcade.c.id).where(arcade_owner.c.user == user_id)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return False
|
||||
return result.fetchall()
|
||||
|
||||
async def get_manager_permissions(self, user_id: int, arcade_id: int) -> Optional[int]:
|
||||
sql = select(arcade_owner.c.permissions).where(and_(arcade_owner.c.user == user_id, arcade_owner.c.arcade == arcade_id))
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
row = result.fetchone()
|
||||
if row:
|
||||
return row['permissions']
|
||||
return None
|
||||
|
||||
async def get_arcade_owners(self, arcade_id: int) -> Optional[Row]:
|
||||
def get_arcade_owners(self, arcade_id: int) -> Optional[Dict]:
|
||||
sql = select(arcade_owner).where(arcade_owner.c.arcade == arcade_id)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def add_arcade_owner(self, arcade_id: int, user_id: int, permissions: int = 1) -> Optional[int]:
|
||||
sql = insert(arcade_owner).values(arcade=arcade_id, user=user_id, permissions=permissions)
|
||||
def add_arcade_owner(self, arcade_id: int, user_id: int) -> None:
|
||||
sql = insert(arcade_owner).values(arcade=arcade_id, user=user_id)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def set_arcade_owner_permissions(self, arcade_id: int, user_id: int, new_permissions: int = 1) -> bool:
|
||||
sql = arcade_owner.update(
|
||||
and_(arcade_owner.c.arcade == arcade_id, arcade_owner.c.user == user_id)
|
||||
).values(permissions = new_permissions)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update arcade owner permissions to {new_permissions} for user {user_id} arcade {arcade_id}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def get_arcade_by_name(self, name: str) -> Optional[List[Row]]:
|
||||
sql = arcade.select(or_(arcade.c.name.like(f"%{name}%"), arcade.c.nickname.like(f"%{name}%")))
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def get_arcades_by_ip(self, ip: str) -> Optional[List[Row]]:
|
||||
sql = arcade.select().where(arcade.c.ip == ip)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def set_arcade_name_nickname(self, arcade_id: int, new_name: Optional[str], new_nickname: Optional[str]) -> bool:
|
||||
sql = arcade.update(arcade.c.id == arcade_id).values(name = new_name, nickname = new_nickname)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update arcade {arcade_id} name to {new_name}/{new_nickname}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_arcade_region_info(self, arcade_id: int, new_country: Optional[str], new_state: Optional[str], new_city: Optional[str], new_region_id: Optional[int], new_country_id: Optional[int]) -> bool:
|
||||
sql = arcade.update(arcade.c.id == arcade_id).values(
|
||||
country = new_country,
|
||||
state = new_state,
|
||||
city = new_city,
|
||||
region_id = new_region_id,
|
||||
country_id = new_country_id
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update arcade {arcade_id} regional info to {new_country}/{new_state}/{new_city}/{new_region_id}/{new_country_id}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_arcade_timezone(self, arcade_id: int, new_timezone: Optional[str]) -> bool:
|
||||
sql = arcade.update(arcade.c.id == arcade_id).values(timezone = new_timezone)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update arcade {arcade_id} timezone to {new_timezone}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def set_arcade_vpn_ip(self, arcade_id: int, new_ip: Optional[str]) -> bool:
|
||||
sql = arcade.update(arcade.c.id == arcade_id).values(ip = new_ip)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update arcade {arcade_id} VPN address to {new_ip}")
|
||||
return False
|
||||
return True
|
||||
|
||||
async def get_num_generated_keychips(self) -> Optional[int]:
|
||||
result = await self.execute(select(func.count("serial LIKE 'A69A%'")).select_from(machine))
|
||||
if result:
|
||||
return result.fetchone()['count_1']
|
||||
self.logger.error("Failed to count machine serials that start with A69A!")
|
||||
|
||||
async def billing_add_charge(self, machine_id: int, game_id: str, game_ver: float, playcount: int, playlimit, product_code: int, product_count: int, func_type: int, player_num: int) -> Optional[int]:
|
||||
result = await self.execute(billing_charge.insert().values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
game_ver=game_ver,
|
||||
play_count=playcount,
|
||||
play_limit=playlimit,
|
||||
product_code=product_code,
|
||||
product_count=product_count,
|
||||
func_type=func_type,
|
||||
player_number=player_num
|
||||
))
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to add billing charge for machine {machine_id}!")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def billing_get_last_charge(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_charge.select(
|
||||
and_(billing_charge.c.machine == machine_id, billing_charge.c.game_id == game_id)
|
||||
).order_by(billing_charge.c.id.desc()).limit(3))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def billing_set_credit(self, machine_id: int, game_id: str, chute_type: int, service_type: int, op_mode: int, coin_rate0: int, coin_rate1: int,
|
||||
bonus_adder: int, coin_to_credit_rate: int, coin_count_slot0: int, coin_count_slot1: int, coin_count_slot2: int, coin_count_slot3: int,
|
||||
coin_count_slot4: int, coin_count_slot5: int, coin_count_slot6: int, coin_count_slot7: int) -> Optional[int]:
|
||||
|
||||
sql = insert(billing_credit).values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
chute_type=chute_type,
|
||||
service_type=service_type,
|
||||
operation_type=op_mode,
|
||||
coin_rate0=coin_rate0,
|
||||
coin_rate1=coin_rate1,
|
||||
coin_bonus=bonus_adder,
|
||||
credit_rate=coin_to_credit_rate,
|
||||
coin_count_slot0=coin_count_slot0,
|
||||
coin_count_slot1=coin_count_slot1,
|
||||
coin_count_slot2=coin_count_slot2,
|
||||
coin_count_slot3=coin_count_slot3,
|
||||
coin_count_slot4=coin_count_slot4,
|
||||
coin_count_slot5=coin_count_slot5,
|
||||
coin_count_slot6=coin_count_slot6,
|
||||
coin_count_slot7=coin_count_slot7,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
chute_type=chute_type,
|
||||
service_type=service_type,
|
||||
operation_type=op_mode,
|
||||
coin_rate0=coin_rate0,
|
||||
coin_rate1=coin_rate1,
|
||||
coin_bonus=bonus_adder,
|
||||
credit_rate=coin_to_credit_rate,
|
||||
coin_count_slot0=coin_count_slot0,
|
||||
coin_count_slot1=coin_count_slot1,
|
||||
coin_count_slot2=coin_count_slot2,
|
||||
coin_count_slot3=coin_count_slot3,
|
||||
coin_count_slot4=coin_count_slot4,
|
||||
coin_count_slot5=coin_count_slot5,
|
||||
coin_count_slot6=coin_count_slot6,
|
||||
coin_count_slot7=coin_count_slot7,
|
||||
)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to set billing credit settings for machine {machine_id}!")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def billing_get_credit(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_credit.select(
|
||||
and_(billing_credit.c.machine == machine_id, billing_credit.c.game_id == game_id)
|
||||
))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def billing_add_playcount(self, machine_id: int, game_id: str, playct: int = 1) -> None:
|
||||
now = datetime.now()
|
||||
sql = insert(billing_playct).values(
|
||||
machine=machine_id,
|
||||
game_id=game_id,
|
||||
year=now.year,
|
||||
month=now.month,
|
||||
playct=playct
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(playct=billing_playct.c.playct + playct)
|
||||
result = await self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to add playcount for machine {machine_id} running {game_id}")
|
||||
|
||||
async def billing_get_playcount_3mo(self, machine_id: int, game_id: str) -> Optional[List[Row]]:
|
||||
result = await self.execute(billing_playct.select(and_(
|
||||
billing_playct.c.machine == machine_id,
|
||||
billing_playct.c.game_id == game_id
|
||||
)).order_by(billing_playct.c.year.desc(), billing_playct.c.month.desc()).limit(3))
|
||||
|
||||
if result is not None:
|
||||
return result.fetchall()
|
||||
|
||||
async def billing_get_last_playcount(self, machine_id: int, game_id: str) -> Optional[Row]:
|
||||
result = await self.execute(billing_playct.select(and_(
|
||||
billing_playct.c.machine == machine_id,
|
||||
billing_playct.c.game_id == game_id
|
||||
)).order_by(billing_playct.c.year.desc(), billing_playct.c.month.desc()).limit(1))
|
||||
|
||||
if result is not None:
|
||||
return result.fetchone()
|
||||
|
||||
async def create_ota_update(self, game_id: str, ver: str, channel: str, app: Optional[str], opt: Optional[str] = None) -> Optional[int]:
|
||||
result = await self.execute(insert(update).values(
|
||||
game = game_id,
|
||||
version = ver,
|
||||
channel = channel,
|
||||
app_ini = app,
|
||||
opt_ini = opt
|
||||
))
|
||||
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to create {game_id} v{ver} update on channel {channel}")
|
||||
return result.lastrowid
|
||||
|
||||
async def get_ota_update(self, game_id: str, ver: str, channel: str) -> Optional[Row]:
|
||||
result = await self.execute(update.select(and_(
|
||||
and_(update.c.game == game_id, update.c.version == ver),
|
||||
update.c.channel == channel
|
||||
)))
|
||||
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def format_serial(
|
||||
self, platform_code: str, platform_rev: int, serial_letter: str, serial_num: int, append: int, dash: bool = False
|
||||
self, platform_code: str, platform_rev: int, serial_num: int, append: int = 4152
|
||||
) -> str:
|
||||
return f"{platform_code}{'-' if dash else ''}{platform_rev:02d}{serial_letter}{serial_num:04d}{append:04d}"
|
||||
return f"{platform_code}{platform_rev:02d}A{serial_num:04d}{append:04d}" # 0x41 = A, 0x52 = R
|
||||
|
||||
def validate_keychip_format(self, serial: str) -> bool:
|
||||
# For the 2nd letter, E and X are the only "real" values that have been observed (A is used for generated keychips)
|
||||
if re.fullmatch(r"^A[0-9]{2}[A-Z][-]?[0-9]{2}[A-HJ-NP-Z][0-9]{4}([0-9]{4})?$", serial) is None:
|
||||
serial = serial.replace("-", "")
|
||||
if len(serial) != 11 or len(serial) != 15:
|
||||
self.logger.error(
|
||||
f"Serial validate failed: Incorrect length for {serial} (len {len(serial)})"
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
platform_code = serial[:4]
|
||||
platform_rev = serial[4:6]
|
||||
const_a = serial[6]
|
||||
num = serial[7:11]
|
||||
append = serial[11:15]
|
||||
|
||||
if re.match("A[7|6]\d[E|X][0|1][0|1|2]A\d{4,8}", serial) is None:
|
||||
self.logger.error(f"Serial validate failed: {serial} failed regex")
|
||||
return False
|
||||
|
||||
if len(append) != 0 or len(append) != 4:
|
||||
self.logger.error(
|
||||
f"Serial validate failed: {serial} had malformed append {append}"
|
||||
)
|
||||
return False
|
||||
|
||||
if len(num) != 4:
|
||||
self.logger.error(
|
||||
f"Serial validate failed: {serial} had malformed number {num}"
|
||||
)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# Thanks bottersnike!
|
||||
def get_keychip_suffix(self, year: int, month: int) -> str:
|
||||
assert year > 1957
|
||||
assert 1 <= month <= 12
|
||||
|
||||
year -= 1957
|
||||
# Jan/Feb/Mar are from the previous tax year
|
||||
if month < 4:
|
||||
year -= 1
|
||||
assert year >= 1 and year <= 99
|
||||
|
||||
month = ((month - 1) + 9) % 12 # Offset so April=0
|
||||
return f"{year:02}{month // 6:01}{month % 6 + 1:01}"
|
||||
|
||||
def parse_keychip_suffix(self, suffix: str) -> tuple[int, int]:
|
||||
year = int(suffix[0:2])
|
||||
half = int(suffix[2])
|
||||
assert half in (0, 1)
|
||||
period = int(suffix[3])
|
||||
assert period in (1, 2, 3, 4, 5, 6)
|
||||
|
||||
month = half * 6 + (period - 1)
|
||||
month = ((month + 3) % 12) + 1 # Offset so Jan=1
|
||||
|
||||
# Jan/Feb/Mar are from the previous tax year
|
||||
if month < 4:
|
||||
year += 1
|
||||
year += 1957
|
||||
|
||||
return (year, month)
|
||||
|
@ -1,36 +1,35 @@
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from random import randrange
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
from typing import Any, Optional, Dict, List
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.engine.cursor import CursorResult
|
||||
from sqlalchemy.engine.base import Connection
|
||||
from sqlalchemy.sql import text, func, select
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func, text
|
||||
from sqlalchemy.types import INTEGER, JSON, TEXT, TIMESTAMP, Integer, String
|
||||
from sqlalchemy import MetaData, Table, Column
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, JSON
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
|
||||
from core.config import CoreConfig
|
||||
|
||||
metadata = MetaData()
|
||||
|
||||
event_log: Table = Table(
|
||||
schema_ver = Table(
|
||||
"schema_versions",
|
||||
metadata,
|
||||
Column("game", String(4), primary_key=True, nullable=False),
|
||||
Column("version", Integer, nullable=False, server_default="1"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
event_log = Table(
|
||||
"event_log",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("system", String(255), nullable=False),
|
||||
Column("type", String(255), nullable=False),
|
||||
Column("severity", Integer, nullable=False),
|
||||
Column("user", INTEGER, ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("arcade", INTEGER, ForeignKey("arcade.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("machine", INTEGER, ForeignKey("machine.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("ip", TEXT(39)),
|
||||
Column("game", TEXT(4)),
|
||||
Column("version", TEXT(24)),
|
||||
Column("message", String(1000), nullable=False),
|
||||
Column("details", JSON, nullable=False),
|
||||
Column("when_logged", TIMESTAMP, nullable=False, server_default=func.now()),
|
||||
@ -39,18 +38,29 @@ event_log: Table = Table(
|
||||
|
||||
|
||||
class BaseData:
|
||||
def __init__(self, cfg: CoreConfig, conn: "sessionmaker[AsyncSession]") -> None:
|
||||
def __init__(self, cfg: CoreConfig, conn: Connection) -> None:
|
||||
self.config = cfg
|
||||
self.conn = conn
|
||||
self.logger = logging.getLogger("database")
|
||||
|
||||
async def execute(self, sql: str, opts: Dict[str, Any] = {}) -> Optional[CursorResult]:
|
||||
def execute(self, sql: str, opts: Dict[str, Any] = {}) -> Optional[CursorResult]:
|
||||
res = None
|
||||
|
||||
async with self.conn() as session:
|
||||
try:
|
||||
self.logger.info(f"SQL Execute: {''.join(str(sql).splitlines())}")
|
||||
res = self.conn.execute(text(sql), opts)
|
||||
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"SQLAlchemy error {e}")
|
||||
return None
|
||||
|
||||
except UnicodeEncodeError as e:
|
||||
self.logger.error(f"UnicodeEncodeError error {e}")
|
||||
return None
|
||||
|
||||
except:
|
||||
try:
|
||||
self.logger.debug(f"SQL Execute: {''.join(str(sql).splitlines())}")
|
||||
res = await session.execute(text(sql), opts)
|
||||
res = self.conn.execute(sql, opts)
|
||||
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"SQLAlchemy error {e}")
|
||||
@ -60,21 +70,9 @@ class BaseData:
|
||||
self.logger.error(f"UnicodeEncodeError error {e}")
|
||||
return None
|
||||
|
||||
except Exception:
|
||||
try:
|
||||
res = await session.execute(sql, opts)
|
||||
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"SQLAlchemy error {e}")
|
||||
return None
|
||||
|
||||
except UnicodeEncodeError as e:
|
||||
self.logger.error(f"UnicodeEncodeError error {e}")
|
||||
return None
|
||||
|
||||
except Exception:
|
||||
self.logger.error(f"Unknown error")
|
||||
raise
|
||||
except:
|
||||
self.logger.error(f"Unknown error")
|
||||
raise
|
||||
|
||||
return res
|
||||
|
||||
@ -84,24 +82,50 @@ class BaseData:
|
||||
"""
|
||||
return randrange(10000, 9999999)
|
||||
|
||||
async def log_event(
|
||||
self, system: str, type: str, severity: int, message: str, details: Dict = {}, user: int = None,
|
||||
arcade: int = None, machine: int = None, ip: Optional[str] = None, game: Optional[str] = None, version: Optional[str] = None
|
||||
def get_all_schema_vers(self) -> Optional[List[Row]]:
|
||||
sql = select(schema_ver)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_schema_ver(self, game: str) -> Optional[int]:
|
||||
sql = select(schema_ver).where(schema_ver.c.game == game)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
|
||||
return row["version"]
|
||||
|
||||
def set_schema_ver(self, ver: int, game: str = "CORE") -> Optional[int]:
|
||||
sql = insert(schema_ver).values(game=game, version=ver)
|
||||
conflict = sql.on_duplicate_key_update(version=ver)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"Failed to update schema version for game {game} (v{ver})"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def log_event(
|
||||
self, system: str, type: str, severity: int, message: str, details: Dict = {}
|
||||
) -> Optional[int]:
|
||||
sql = event_log.insert().values(
|
||||
system=system,
|
||||
type=type,
|
||||
severity=severity,
|
||||
user=user,
|
||||
arcade=arcade,
|
||||
machine=machine,
|
||||
ip=ip,
|
||||
game=game,
|
||||
version=version,
|
||||
message=message,
|
||||
details=json.dumps(details),
|
||||
)
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
@ -111,9 +135,9 @@ class BaseData:
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
async def get_event_log(self, entries: int = 100) -> Optional[List[Row]]:
|
||||
sql = event_log.select().order_by(event_log.c.id.desc()).limit(entries)
|
||||
result = await self.execute(sql)
|
||||
def get_event_log(self, entries: int = 100) -> Optional[List[Dict]]:
|
||||
sql = event_log.select().limit(entries).all()
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None:
|
||||
return None
|
||||
@ -121,8 +145,6 @@ class BaseData:
|
||||
|
||||
def fix_bools(self, data: Dict) -> Dict:
|
||||
for k, v in data.items():
|
||||
if k == "userName" or k == "teamName":
|
||||
continue
|
||||
if type(v) == str and v.lower() == "true":
|
||||
data[k] = True
|
||||
elif type(v) == str and v.lower() == "false":
|
||||
|
@ -1,160 +1,96 @@
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from sqlalchemy import Column, Table, UniqueConstraint
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import Integer, String, Boolean, TIMESTAMP
|
||||
from sqlalchemy.sql.schema import ForeignKey
|
||||
from sqlalchemy.types import BIGINT, TIMESTAMP, VARCHAR, Boolean, Integer, String
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.engine import Row
|
||||
|
||||
from core.data.schema.base import BaseData, metadata
|
||||
|
||||
aime_card: Table = Table(
|
||||
aime_card = Table(
|
||||
"aime_card",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column("access_code", String(20), nullable=False, unique=True),
|
||||
Column("idm", String(16), unique=True),
|
||||
Column("chip_id", BIGINT, unique=True),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("access_code", String(20)),
|
||||
Column("created_date", TIMESTAMP, server_default=func.now()),
|
||||
Column("last_login_date", TIMESTAMP, onupdate=func.now()),
|
||||
Column("is_locked", Boolean, server_default="0"),
|
||||
Column("is_banned", Boolean, server_default="0"),
|
||||
Column("memo", VARCHAR(16)),
|
||||
UniqueConstraint("user", "access_code", name="aime_card_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class CardData(BaseData):
|
||||
moble_os_codes = set([0x06, 0x07, 0x10, 0x12, 0x13, 0x14, 0x15, 0x17, 0x18])
|
||||
card_os_codes = set([0x20, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7])
|
||||
|
||||
async def get_card_by_access_code(self, access_code: str) -> Optional[Row]:
|
||||
def get_card_by_access_code(self, access_code: str) -> Optional[Row]:
|
||||
sql = aime_card.select(aime_card.c.access_code == access_code)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
async def get_card_by_id(self, card_id: int) -> Optional[Row]:
|
||||
def get_card_by_id(self, card_id: int) -> Optional[Row]:
|
||||
sql = aime_card.select(aime_card.c.id == card_id)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
async def update_access_code(self, old_ac: str, new_ac: str) -> None:
|
||||
def update_access_code(self, old_ac: str, new_ac: str) -> None:
|
||||
sql = aime_card.update(aime_card.c.access_code == old_ac).values(
|
||||
access_code=new_ac
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"Failed to change card access code from {old_ac} to {new_ac}"
|
||||
)
|
||||
|
||||
async def get_user_id_from_card(self, access_code: str) -> Optional[int]:
|
||||
def get_user_id_from_card(self, access_code: str) -> Optional[int]:
|
||||
"""
|
||||
Given a 20 digit access code as a string, get the user id associated with that card
|
||||
"""
|
||||
card = await self.get_card_by_access_code(access_code)
|
||||
card = self.get_card_by_access_code(access_code)
|
||||
if card is None:
|
||||
return None
|
||||
|
||||
return int(card["user"])
|
||||
|
||||
async def get_card_banned(self, access_code: str) -> Optional[bool]:
|
||||
"""
|
||||
Given a 20 digit access code as a string, check if the card is banned
|
||||
"""
|
||||
card = await self.get_card_by_access_code(access_code)
|
||||
if card is None:
|
||||
return None
|
||||
if card["is_banned"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def get_card_locked(self, access_code: str) -> Optional[bool]:
|
||||
"""
|
||||
Given a 20 digit access code as a string, check if the card is locked
|
||||
"""
|
||||
card = await self.get_card_by_access_code(access_code)
|
||||
if card is None:
|
||||
return None
|
||||
if card["is_locked"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def delete_card(self, card_id: int) -> None:
|
||||
def delete_card(self, card_id: int) -> None:
|
||||
sql = aime_card.delete(aime_card.c.id == card_id)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to delete card with id {card_id}")
|
||||
|
||||
async def get_user_cards(self, aime_id: int) -> Optional[List[Row]]:
|
||||
def get_user_cards(self, aime_id: int) -> Optional[List[Row]]:
|
||||
"""
|
||||
Returns all cards owned by a user
|
||||
"""
|
||||
sql = aime_card.select(aime_card.c.user == aime_id)
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def create_card(self, user_id: int, access_code: str) -> Optional[int]:
|
||||
def create_card(self, user_id: int, access_code: str) -> Optional[int]:
|
||||
"""
|
||||
Given a aime_user id and a 20 digit access code as a string, create a card and return the ID if successful
|
||||
"""
|
||||
sql = aime_card.insert().values(user=user_id, access_code=access_code)
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def update_card_last_login(self, access_code: str) -> None:
|
||||
sql = aime_card.update(aime_card.c.access_code == access_code).values(
|
||||
last_login_date=func.now()
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(f"Failed to update last login time for {access_code}")
|
||||
|
||||
async def get_card_by_idm(self, idm: str) -> Optional[Row]:
|
||||
result = await self.execute(aime_card.select(aime_card.c.idm == idm))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def get_card_by_chip_id(self, chip_id: int) -> Optional[Row]:
|
||||
result = await self.execute(aime_card.select(aime_card.c.chip_id == chip_id))
|
||||
if result:
|
||||
return result.fetchone()
|
||||
|
||||
async def set_chip_id_by_access_code(self, access_code: str, chip_id: int) -> Optional[Row]:
|
||||
result = await self.execute(aime_card.update(aime_card.c.access_code == access_code).values(chip_id=chip_id))
|
||||
if not result:
|
||||
self.logger.error(f"Failed to update chip ID to {chip_id} for {access_code}")
|
||||
|
||||
async def set_idm_by_access_code(self, access_code: str, idm: str) -> Optional[Row]:
|
||||
result = await self.execute(aime_card.update(aime_card.c.access_code == access_code).values(idm=idm))
|
||||
if not result:
|
||||
self.logger.error(f"Failed to update IDm to {idm} for {access_code}")
|
||||
|
||||
async def set_access_code_by_access_code(self, old_ac: str, new_ac: str) -> None:
|
||||
result = await self.execute(aime_card.update(aime_card.c.access_code == old_ac).values(access_code=new_ac))
|
||||
if not result:
|
||||
self.logger.error(f"Failed to change card access code from {old_ac} to {new_ac}")
|
||||
|
||||
async def set_memo_by_access_code(self, access_code: str, memo: str) -> None:
|
||||
result = await self.execute(aime_card.update(aime_card.c.access_code == access_code).values(memo=memo))
|
||||
if not result:
|
||||
self.logger.error(f"Failed to add memo to card {access_code}")
|
||||
|
||||
def to_access_code(self, luid: str) -> str:
|
||||
"""
|
||||
Given a felica cards internal 16 hex character luid, convert it to a 0-padded 20 digit access code as a string
|
||||
@ -165,4 +101,4 @@ class CardData(BaseData):
|
||||
"""
|
||||
Given a 20 digit access code as a string, return the 16 hex character luid
|
||||
"""
|
||||
return f"{int(access_code):0{16}X}"
|
||||
return f"{int(access_code):0{16}x}"
|
||||
|
@ -1,15 +1,16 @@
|
||||
from typing import List, Optional
|
||||
|
||||
import bcrypt
|
||||
from sqlalchemy import Column, Table
|
||||
from enum import Enum
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import Table, Column
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.types import TIMESTAMP, Integer, String
|
||||
from sqlalchemy.engine import Row
|
||||
import bcrypt
|
||||
|
||||
from core.data.schema.base import BaseData, metadata
|
||||
|
||||
aime_user: Table = Table(
|
||||
aime_user = Table(
|
||||
"aime_user",
|
||||
metadata,
|
||||
Column("id", Integer, nullable=False, primary_key=True, autoincrement=True),
|
||||
@ -23,13 +24,20 @@ aime_user: Table = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class PermissionBits(Enum):
|
||||
PermUser = 1
|
||||
PermMod = 2
|
||||
PermSysAdmin = 4
|
||||
|
||||
|
||||
class UserData(BaseData):
|
||||
async def create_user(
|
||||
def create_user(
|
||||
self,
|
||||
id: Optional[int] = None,
|
||||
username: Optional[str] = None,
|
||||
email: Optional[str] = None,
|
||||
password: Optional[str] = None,
|
||||
id: int = None,
|
||||
username: str = None,
|
||||
email: str = None,
|
||||
password: str = None,
|
||||
permission: int = 1,
|
||||
) -> Optional[int]:
|
||||
if id is None:
|
||||
@ -52,87 +60,47 @@ class UserData(BaseData):
|
||||
username=username, email=email, password=password, permissions=permission
|
||||
)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def get_user(self, user_id: int) -> Optional[Row]:
|
||||
def get_user(self, user_id: int) -> Optional[Row]:
|
||||
sql = select(aime_user).where(aime_user.c.id == user_id)
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return False
|
||||
return result.fetchone()
|
||||
|
||||
async def check_password(self, user_id: int, passwd: bytes = None) -> bool:
|
||||
usr = await self.get_user(user_id)
|
||||
def check_password(self, user_id: int, passwd: bytes = None) -> bool:
|
||||
usr = self.get_user(user_id)
|
||||
if usr is None:
|
||||
return False
|
||||
|
||||
if usr["password"] is None:
|
||||
return False
|
||||
|
||||
if passwd is None or not passwd:
|
||||
return False
|
||||
|
||||
return bcrypt.checkpw(passwd, usr["password"].encode())
|
||||
|
||||
async def delete_user(self, user_id: int) -> None:
|
||||
def reset_autoincrement(self, ai_value: int) -> None:
|
||||
# ALTER TABLE isn't in sqlalchemy so we do this the ugly way
|
||||
sql = f"ALTER TABLE aime_user AUTO_INCREMENT={ai_value}"
|
||||
self.execute(sql)
|
||||
|
||||
def delete_user(self, user_id: int) -> None:
|
||||
sql = aime_user.delete(aime_user.c.id == user_id)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to delete user with id {user_id}")
|
||||
|
||||
async def get_unregistered_users(self) -> List[Row]:
|
||||
def get_unregistered_users(self) -> List[Row]:
|
||||
"""
|
||||
Returns a list of users who have not registered with the webui. They may or may not have cards.
|
||||
"""
|
||||
sql = select(aime_user).where(aime_user.c.password == None)
|
||||
|
||||
result = await self.execute(sql)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def find_user_by_email(self, email: str) -> Row:
|
||||
sql = select(aime_user).where(aime_user.c.email == email)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return False
|
||||
return result.fetchone()
|
||||
|
||||
async def find_user_by_username(self, username: str) -> List[Row]:
|
||||
sql = aime_user.select(aime_user.c.username.like(f"%{username}%"))
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return False
|
||||
return result.fetchall()
|
||||
|
||||
async def change_password(self, user_id: int, new_passwd: str) -> bool:
|
||||
sql = aime_user.update(aime_user.c.id == user_id).values(password = new_passwd)
|
||||
|
||||
result = await self.execute(sql)
|
||||
return result is not None
|
||||
|
||||
async def change_username(self, user_id: int, new_name: str) -> bool:
|
||||
sql = aime_user.update(aime_user.c.id == user_id).values(username = new_name)
|
||||
|
||||
result = await self.execute(sql)
|
||||
return result is not None
|
||||
|
||||
async def get_user_by_username(self, username: str) -> Optional[Row]:
|
||||
result = await self.execute(aime_user.select(aime_user.c.username == username))
|
||||
if result: return result.fetchone()
|
||||
|
||||
async def change_permission(self, user_id: int, new_perms: int) -> Optional[bool]:
|
||||
sql = aime_user.update(aime_user.c.id == user_id).values(permissions = new_perms)
|
||||
|
||||
result = await self.execute(sql)
|
||||
return result is not None
|
||||
|
||||
async def change_email(self, user_id: int, new_email: int) -> Optional[bool]:
|
||||
sql = aime_user.update(aime_user.c.id == user_id).values(email = new_email)
|
||||
|
||||
result = await self.execute(sql)
|
||||
return result is not None
|
||||
|
@ -1,3 +0,0 @@
|
||||
ALTER TABLE machine DROP COLUMN memo;
|
||||
ALTER TABLE machine DROP COLUMN is_blacklisted;
|
||||
ALTER TABLE machine DROP COLUMN `data`;
|
@ -1 +0,0 @@
|
||||
ALTER TABLE arcade DROP COLUMN 'ip';
|
@ -1,3 +0,0 @@
|
||||
ALTER TABLE machine ADD memo varchar(255) NULL;
|
||||
ALTER TABLE machine ADD is_blacklisted tinyint(1) NULL;
|
||||
ALTER TABLE machine ADD `data` longtext NULL;
|
@ -1 +0,0 @@
|
||||
ALTER TABLE arcade ADD ip varchar(39) NULL;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE diva_profile
|
||||
DROP skn_eqp;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE diva_profile
|
||||
ADD skn_eqp INT NOT NULL DEFAULT 0;
|
@ -1,30 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
DROP COLUMN regionId,
|
||||
DROP COLUMN machineType;
|
||||
|
||||
ALTER TABLE chuni_static_events
|
||||
DROP COLUMN startDate;
|
||||
|
||||
ALTER TABLE chuni_profile_data
|
||||
DROP COLUMN rankUpChallengeResults;
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus
|
||||
DROP FOREIGN KEY chuni_static_login_bonus_ibfk_1;
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
CHANGE COLUMN presetId id INT NOT NULL;
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
ADD PRIMARY KEY(id);
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
ADD CONSTRAINT chuni_static_login_bonus_preset_uk UNIQUE(id, version);
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus
|
||||
ADD CONSTRAINT chuni_static_login_bonus_ibfk_1 FOREIGN KEY(presetId)
|
||||
REFERENCES chuni_static_login_bonus_preset(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -1,12 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
CHANGE COLUMN isClear isClear TINYINT(1) NULL DEFAULT NULL;
|
||||
|
||||
ALTER TABLE chuni_score_best
|
||||
CHANGE COLUMN isSuccess isSuccess TINYINT(1) NULL DEFAULT NULL ;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
DROP COLUMN ticketId;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -1,29 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
ADD COLUMN regionId INT,
|
||||
ADD COLUMN machineType INT;
|
||||
|
||||
ALTER TABLE chuni_static_events
|
||||
ADD COLUMN startDate TIMESTAMP NOT NULL DEFAULT current_timestamp();
|
||||
|
||||
ALTER TABLE chuni_profile_data
|
||||
ADD COLUMN rankUpChallengeResults JSON;
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus
|
||||
DROP FOREIGN KEY chuni_static_login_bonus_ibfk_1;
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
CHANGE COLUMN id presetId INT NOT NULL;
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
DROP PRIMARY KEY;
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
DROP INDEX chuni_static_login_bonus_preset_uk;
|
||||
ALTER TABLE chuni_static_login_bonus_preset
|
||||
ADD CONSTRAINT chuni_static_login_bonus_preset_pk PRIMARY KEY (presetId, version);
|
||||
|
||||
ALTER TABLE chuni_static_login_bonus
|
||||
ADD CONSTRAINT chuni_static_login_bonus_ibfk_1 FOREIGN KEY (presetId, version)
|
||||
REFERENCES chuni_static_login_bonus_preset(presetId, version) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -1,12 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
CHANGE COLUMN isClear isClear TINYINT(6) NULL DEFAULT NULL;
|
||||
|
||||
ALTER TABLE chuni_score_best
|
||||
CHANGE COLUMN isSuccess isSuccess INT(11) NULL DEFAULT NULL ;
|
||||
|
||||
ALTER TABLE chuni_score_playlog
|
||||
ADD COLUMN ticketId INT(11) NULL AFTER machineType;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE ongeki_static_events
|
||||
DROP COLUMN startDate;
|
@ -1,22 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
ALTER TABLE ongeki_user_event_point DROP COLUMN version;
|
||||
ALTER TABLE ongeki_user_event_point DROP COLUMN `rank`;
|
||||
ALTER TABLE ongeki_user_event_point DROP COLUMN `type`;
|
||||
ALTER TABLE ongeki_user_event_point DROP COLUMN date;
|
||||
|
||||
ALTER TABLE ongeki_user_tech_event DROP COLUMN version;
|
||||
|
||||
ALTER TABLE ongeki_user_mission_point DROP COLUMN version;
|
||||
|
||||
ALTER TABLE ongeki_static_events DROP COLUMN endDate;
|
||||
|
||||
DROP TABLE ongeki_tech_event_ranking;
|
||||
DROP TABLE ongeki_static_music_ranking_list;
|
||||
DROP TABLE ongeki_static_rewards;
|
||||
DROP TABLE ongeki_static_present_list;
|
||||
DROP TABLE ongeki_static_tech_music;
|
||||
DROP TABLE ongeki_static_client_testmode;
|
||||
DROP TABLE ongeki_static_game_point;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE ongeki_static_events
|
||||
ADD COLUMN startDate TIMESTAMP NOT NULL DEFAULT current_timestamp();
|
@ -1,98 +0,0 @@
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
ALTER TABLE ongeki_user_event_point ADD COLUMN version INTEGER NOT NULL;
|
||||
ALTER TABLE ongeki_user_event_point ADD COLUMN `rank` INTEGER;
|
||||
ALTER TABLE ongeki_user_event_point ADD COLUMN `type` INTEGER NOT NULL;
|
||||
ALTER TABLE ongeki_user_event_point ADD COLUMN date VARCHAR(25);
|
||||
|
||||
ALTER TABLE ongeki_user_tech_event ADD COLUMN version INTEGER NOT NULL;
|
||||
|
||||
ALTER TABLE ongeki_user_mission_point ADD COLUMN version INTEGER NOT NULL;
|
||||
|
||||
ALTER TABLE ongeki_static_events ADD COLUMN endDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
|
||||
CREATE TABLE ongeki_tech_event_ranking (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
user INT NOT NULL,
|
||||
version INT NOT NULL,
|
||||
date VARCHAR(25),
|
||||
eventId INT NOT NULL,
|
||||
`rank` INT,
|
||||
totalPlatinumScore INT NOT NULL,
|
||||
totalTechScore INT NOT NULL,
|
||||
UNIQUE KEY ongeki_tech_event_ranking_uk (user, eventId),
|
||||
CONSTRAINT ongeki_tech_event_ranking_ibfk1 FOREIGN KEY (user) REFERENCES aime_user(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_music_ranking_list (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
version INT NOT NULL,
|
||||
musicId INT NOT NULL,
|
||||
point INT NOT NULL,
|
||||
userName VARCHAR(255),
|
||||
UNIQUE KEY ongeki_static_music_ranking_list_uk (version, musicId)
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_rewards (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
version INT NOT NULL,
|
||||
rewardId INT NOT NULL,
|
||||
rewardName VARCHAR(255) NOT NULL,
|
||||
itemKind INT NOT NULL,
|
||||
itemId INT NOT NULL,
|
||||
UNIQUE KEY ongeki_tech_event_ranking_uk (version, rewardId)
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_present_list (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
version INT NOT NULL,
|
||||
presentId INT NOT NULL,
|
||||
presentName VARCHAR(255) NOT NULL,
|
||||
rewardId INT NOT NULL,
|
||||
stock INT NOT NULL,
|
||||
message VARCHAR(255),
|
||||
startDate VARCHAR(25) NOT NULL,
|
||||
endDate VARCHAR(25) NOT NULL,
|
||||
UNIQUE KEY ongeki_static_present_list_uk (version, presentId, rewardId)
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_tech_music (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
version INT NOT NULL,
|
||||
eventId INT NOT NULL,
|
||||
musicId INT NOT NULL,
|
||||
level INT NOT NULL,
|
||||
UNIQUE KEY ongeki_static_tech_music_uk (version, musicId, eventId)
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_client_testmode (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
regionId INT NOT NULL,
|
||||
placeId INT NOT NULL,
|
||||
clientId VARCHAR(11) NOT NULL,
|
||||
updateDate TIMESTAMP NOT NULL,
|
||||
isDelivery BOOLEAN NOT NULL,
|
||||
groupId INT NOT NULL,
|
||||
groupRole INT NOT NULL,
|
||||
continueMode INT NOT NULL,
|
||||
selectMusicTime INT NOT NULL,
|
||||
advertiseVolume INT NOT NULL,
|
||||
eventMode INT NOT NULL,
|
||||
eventMusicNum INT NOT NULL,
|
||||
patternGp INT NOT NULL,
|
||||
limitGp INT NOT NULL,
|
||||
maxLeverMovable INT NOT NULL,
|
||||
minLeverMovable INT NOT NULL,
|
||||
UNIQUE KEY ongeki_static_client_testmode_uk (clientId)
|
||||
);
|
||||
|
||||
CREATE TABLE ongeki_static_game_point (
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
`type` INT NOT NULL,
|
||||
cost INT NOT NULL,
|
||||
startDate VARCHAR(25) NOT NULL DEFAULT "2000-01-01 05:00:00.0",
|
||||
endDate VARCHAR(25) NOT NULL DEFAULT "2099-01-01 05:00:00.0",
|
||||
UNIQUE KEY ongeki_static_game_point_uk (`type`)
|
||||
);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
@ -1,3 +0,0 @@
|
||||
ALTER TABLE mai2_item_card
|
||||
CHANGE COLUMN startDate startDate TIMESTAMP DEFAULT "2018-01-01 00:00:00.0",
|
||||
CHANGE COLUMN endDate endDate TIMESTAMP DEFAULT "2038-01-01 00:00:00.0";
|
@ -1,78 +0,0 @@
|
||||
DELETE FROM mai2_static_event WHERE version < 13;
|
||||
UPDATE mai2_static_event SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_static_music WHERE version < 13;
|
||||
UPDATE mai2_static_music SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_static_ticket WHERE version < 13;
|
||||
UPDATE mai2_static_ticket SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_static_cards WHERE version < 13;
|
||||
UPDATE mai2_static_cards SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_profile_detail WHERE version < 13;
|
||||
UPDATE mai2_profile_detail SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_profile_extend WHERE version < 13;
|
||||
UPDATE mai2_profile_extend SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_profile_option WHERE version < 13;
|
||||
UPDATE mai2_profile_option SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_profile_ghost WHERE version < 13;
|
||||
UPDATE mai2_profile_ghost SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DELETE FROM mai2_profile_rating WHERE version < 13;
|
||||
UPDATE mai2_profile_rating SET version = version - 13 WHERE version >= 13;
|
||||
|
||||
DROP TABLE maimai_score_best;
|
||||
DROP TABLE maimai_playlog;
|
||||
DROP TABLE maimai_profile_detail;
|
||||
DROP TABLE maimai_profile_option;
|
||||
DROP TABLE maimai_profile_web_option;
|
||||
DROP TABLE maimai_profile_grade_status;
|
||||
|
||||
ALTER TABLE mai2_item_character DROP COLUMN point;
|
||||
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN cardId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN cardTypeId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN charaId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN mapId int(11) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN characterId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN level int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN awakening int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN useCount int(11) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_charge MODIFY COLUMN chargeId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_charge MODIFY COLUMN stock int(11) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_favorite MODIFY COLUMN itemKind int(11) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN seasonId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN point int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN `rank` int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN rewardGet tinyint(1) NOT NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN userName varchar(8) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN itemId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN itemKind int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN stock int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN isValid tinyint(1) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN bonusId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN point int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN isCurrent tinyint(1) NOT NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN isComplete tinyint(1) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN mapId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN distance int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isLock tinyint(1) NOT NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isClear tinyint(1) NOT NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isComplete tinyint(1) NOT NULL;
|
||||
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN printDate timestamp DEFAULT current_timestamp() NOT NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN serialId varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN placeId int(11) NOT NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN clientId varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN printerSerialId varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
|
@ -1,3 +0,0 @@
|
||||
ALTER TABLE mai2_item_card
|
||||
CHANGE COLUMN startDate startDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CHANGE COLUMN endDate endDate TIMESTAMP NOT NULL;
|
@ -1 +0,0 @@
|
||||
DROP TABLE aime.mai2_profile_consec_logins;
|
@ -1,62 +0,0 @@
|
||||
UPDATE mai2_static_event SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_static_music SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_static_ticket SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_static_cards SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_profile_detail SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_profile_extend SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_profile_option SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_profile_ghost SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
UPDATE mai2_profile_rating SET version = version + 13 WHERE version < 1000;
|
||||
|
||||
ALTER TABLE mai2_item_character ADD point int(11) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN cardId int(11) NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN cardTypeId int(11) NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN charaId int(11) NULL;
|
||||
ALTER TABLE mai2_item_card MODIFY COLUMN mapId int(11) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN characterId int(11) NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN level int(11) NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN awakening int(11) NULL;
|
||||
ALTER TABLE mai2_item_character MODIFY COLUMN useCount int(11) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_charge MODIFY COLUMN chargeId int(11) NULL;
|
||||
ALTER TABLE mai2_item_charge MODIFY COLUMN stock int(11) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_favorite MODIFY COLUMN itemKind int(11) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN seasonId int(11) NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN point int(11) NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN `rank` int(11) NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN rewardGet tinyint(1) NULL;
|
||||
ALTER TABLE mai2_item_friend_season_ranking MODIFY COLUMN userName varchar(8) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN itemId int(11) NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN itemKind int(11) NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN stock int(11) NULL;
|
||||
ALTER TABLE mai2_item_item MODIFY COLUMN isValid tinyint(1) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN bonusId int(11) NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN point int(11) NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN isCurrent tinyint(1) NULL;
|
||||
ALTER TABLE mai2_item_login_bonus MODIFY COLUMN isComplete tinyint(1) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN mapId int(11) NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN distance int(11) NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isLock tinyint(1) NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isClear tinyint(1) NULL;
|
||||
ALTER TABLE mai2_item_map MODIFY COLUMN isComplete tinyint(1) NULL;
|
||||
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN printDate timestamp DEFAULT current_timestamp() NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN serialId varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN placeId int(11) NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN clientId varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;
|
||||
ALTER TABLE mai2_item_print_detail MODIFY COLUMN printerSerialId varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;
|
@ -1,10 +0,0 @@
|
||||
ALTER TABLE mai2_profile_detail
|
||||
DROP COLUMN mapStock;
|
||||
|
||||
ALTER TABLE mai2_profile_extend
|
||||
DROP COLUMN selectResultScoreViewType;
|
||||
|
||||
ALTER TABLE mai2_profile_option
|
||||
DROP COLUMN outFrameType,
|
||||
DROP COLUMN touchVolume,
|
||||
DROP COLUMN breakSlideVolume;
|
@ -1,9 +0,0 @@
|
||||
CREATE TABLE `mai2_profile_consec_logins` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user` int(11) NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`logins` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `mai2_profile_consec_logins_uk` (`user`,`version`),
|
||||
CONSTRAINT `mai2_profile_consec_logins_ibfk_1` FOREIGN KEY (`user`) REFERENCES `aime_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
@ -1,10 +0,0 @@
|
||||
ALTER TABLE mai2_profile_detail
|
||||
ADD mapStock INT NULL AFTER playCount;
|
||||
|
||||
ALTER TABLE mai2_profile_extend
|
||||
ADD selectResultScoreViewType INT NULL AFTER selectResultDetails;
|
||||
|
||||
ALTER TABLE mai2_profile_option
|
||||
ADD outFrameType INT NULL AFTER dispCenter,
|
||||
ADD touchVolume INT NULL AFTER slideVolume,
|
||||
ADD breakSlideVolume INT NULL AFTER slideVolume;
|
1290
core/frontend.py
1290
core/frontend.py
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>Create User</h1>
|
||||
<form id="create" style="max-width: 240px; min-width: 10%;" action="/gate/gate.create" method="post">
|
32
core/frontend/gate/gate.jinja
Normal file
32
core/frontend/gate/gate.jinja
Normal file
@ -0,0 +1,32 @@
|
||||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>Gate</h1>
|
||||
{% include "core/frontend/widgets/err_banner.jinja" %}
|
||||
<style>
|
||||
/* Chrome, Safari, Edge, Opera */
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Firefox */
|
||||
input[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
</style>
|
||||
<form id="login" style="max-width: 240px; min-width: 10%;" action="/gate/gate.login" method="post">
|
||||
<div class="form-group row">
|
||||
<label for="access_code">Card Access Code</label><br>
|
||||
<input form="login" class="form-control" name="access_code" id="access_code" type="number" placeholder="00000000000000000000" maxlength="20" required>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="passwd">Password</label><br>
|
||||
<input id="passwd" class="form-control" name="passwd" type="password" placeholder="password">
|
||||
</div>
|
||||
<p></p>
|
||||
<input id="submit" class="btn btn-primary" style="display: block; margin: 0 auto;" form="login" type="submit" value="Login">
|
||||
</form>
|
||||
<h6>*To register for the webui, type in the access code of your card, as shown in a game, and leave the password field blank.</h6>
|
||||
<h6>*If you have not registered a card with this server, you cannot create a webui account.</h6>
|
||||
{% endblock content %}
|
@ -4,7 +4,6 @@
|
||||
<title>{{ title }}</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
html {
|
||||
background-color: #181a1b !important;
|
||||
@ -78,13 +77,10 @@
|
||||
margin-bottom: 10px;
|
||||
width: 15%;
|
||||
}
|
||||
.modal-content {
|
||||
background-color: #181a1b;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% include "core/templates/widgets/topbar.jinja" %}
|
||||
{% include "core/frontend/widgets/topbar.jinja" %}
|
||||
{% block content %}
|
||||
<h1>{{ server_name }}</h1>
|
||||
{% endblock content %}
|
4
core/frontend/user/index.jinja
Normal file
4
core/frontend/user/index.jinja
Normal file
@ -0,0 +1,4 @@
|
||||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>testing</h1>
|
||||
{% endblock content %}
|
14
core/frontend/widgets/err_banner.jinja
Normal file
14
core/frontend/widgets/err_banner.jinja
Normal file
@ -0,0 +1,14 @@
|
||||
{% if error > 0 %}
|
||||
<div class="err-banner">
|
||||
<h3>Error</h3>
|
||||
{% if error == 1 %}
|
||||
Card not registered, or wrong password
|
||||
{% elif error == 2 %}
|
||||
Missing or malformed access code
|
||||
{% elif error == 3 %}
|
||||
Failed to create user
|
||||
{% else %}
|
||||
An unknown error occoured
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
18
core/frontend/widgets/topbar.jinja
Normal file
18
core/frontend/widgets/topbar.jinja
Normal file
@ -0,0 +1,18 @@
|
||||
<div style="background: #333; color: #f9f9f9; width: 10%; height: 50px; line-height: 50px; text-align: center; float: left;">
|
||||
Navigation
|
||||
</div>
|
||||
<div style="background: #333; color: #f9f9f9; width: 80%; height: 50px; line-height: 50px; padding-left: 10px; float: left;">
|
||||
<a href=/><button class="btn btn-primary">Home</button></a>
|
||||
{% for game in game_list %}
|
||||
<a href=game/{{ game.url }}><button class="btn btn-success">{{ game.name }}</button></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div style="background: #333; color: #f9f9f9; width: 10%; height: 50px; line-height: 50px; text-align: center; float: left;">
|
||||
{% if sesh is defined and sesh["userId"] > 0 %}
|
||||
<a href="/user"><button class="btn btn-primary">Account</button></a>
|
||||
{% else %}
|
||||
<a href="/gate"><button class="btn btn-primary">Gate</button></a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
300
core/mucha.py
300
core/mucha.py
@ -1,23 +1,20 @@
|
||||
from typing import Dict, Any, Optional
|
||||
from typing import Dict, Any, Optional, List
|
||||
import logging, coloredlogs
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import PlainTextResponse
|
||||
from twisted.web import resource
|
||||
from twisted.web.http import Request
|
||||
from datetime import datetime
|
||||
from Crypto.Cipher import Blowfish
|
||||
import pytz
|
||||
|
||||
from .config import CoreConfig
|
||||
from .utils import Utils
|
||||
from .title import TitleServlet
|
||||
from .data import Data
|
||||
from .const import *
|
||||
from core import CoreConfig
|
||||
from core.utils import Utils
|
||||
|
||||
|
||||
class MuchaServlet:
|
||||
mucha_registry: Dict[str, Dict[str, str]] = {}
|
||||
def __init__(self, cfg: CoreConfig, cfg_dir: str) -> None:
|
||||
self.config = cfg
|
||||
self.config_dir = cfg_dir
|
||||
self.mucha_registry: List[str] = []
|
||||
|
||||
self.logger = logging.getLogger("mucha")
|
||||
log_fmt_str = "[%(asctime)s] Mucha | %(levelname)s | %(message)s"
|
||||
@ -36,150 +33,72 @@ class MuchaServlet:
|
||||
self.logger.addHandler(fileHandler)
|
||||
self.logger.addHandler(consoleHandler)
|
||||
|
||||
self.logger.setLevel(cfg.mucha.loglevel)
|
||||
coloredlogs.install(level=cfg.mucha.loglevel, logger=self.logger, fmt=log_fmt_str)
|
||||
|
||||
self.data = Data(cfg)
|
||||
self.logger.setLevel(logging.INFO)
|
||||
coloredlogs.install(level=logging.INFO, logger=self.logger, fmt=log_fmt_str)
|
||||
|
||||
for _, mod in TitleServlet.title_registry.items():
|
||||
enabled, game_cds, netids = mod.get_mucha_info(self.config, self.config_dir)
|
||||
if enabled:
|
||||
for x in range(len(game_cds)):
|
||||
self.mucha_registry[game_cds[x]] = { "netid_prefix": netids[x] }
|
||||
all_titles = Utils.get_all_titles()
|
||||
|
||||
for _, mod in all_titles.items():
|
||||
if hasattr(mod, "index") and hasattr(mod.index, "get_mucha_info"):
|
||||
enabled, game_cd = mod.index.get_mucha_info(
|
||||
self.config, self.config_dir
|
||||
)
|
||||
if enabled:
|
||||
self.mucha_registry.append(game_cd)
|
||||
|
||||
self.logger.info(f"Serving {len(self.mucha_registry)} games")
|
||||
|
||||
async def handle_boardauth(self, request: Request) -> bytes:
|
||||
bod = await request.body()
|
||||
req_dict = self.mucha_preprocess(bod)
|
||||
def handle_boardauth(self, request: Request, _: Dict) -> bytes:
|
||||
req_dict = self.mucha_preprocess(request.content.getvalue())
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
|
||||
if req_dict is None:
|
||||
self.logger.error(
|
||||
f"Error processing mucha request {bod}"
|
||||
f"Error processing mucha request {request.content.getvalue()}"
|
||||
)
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
return b""
|
||||
|
||||
req = MuchaAuthRequest(req_dict)
|
||||
self.logger.debug(f"Mucha request {vars(req)}")
|
||||
|
||||
if not req.gameCd or not req.gameVer or not req.sendDate or not req.countryCd or not req.serialNum:
|
||||
self.logger.warning(f"Missing required fields - {vars(req)}")
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
minfo = self.mucha_registry.get(req.gameCd, {})
|
||||
|
||||
if not minfo:
|
||||
self.logger.warning(f"Unknown gameCd {req.gameCd} from {client_ip}")
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
b_key = b""
|
||||
for x in range(8):
|
||||
b_key += req.sendDate[(x - 1) & 7].encode()
|
||||
|
||||
b_iv = b_key # what the fuck namco
|
||||
|
||||
cipher = Blowfish.new(b_key, Blowfish.MODE_CBC, b_iv)
|
||||
try:
|
||||
sn_decrypt = cipher.decrypt(bytes.fromhex(req.serialNum))[:12].decode()
|
||||
except Exception as e:
|
||||
self.logger.error(f"Decrypt SN {req.serialNum} failed! - {e}")
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
self.logger.info(f"Boardauth request from {sn_decrypt} ({client_ip}) for {req.gameVer}")
|
||||
|
||||
resp = MuchaAuthResponse(
|
||||
f"{self.config.server.hostname}{':' + str(self.config.server.port) if not self.config.server.is_using_proxy else ''}"
|
||||
)
|
||||
|
||||
netid = minfo.get('netid_prefix', "ABxN") + sn_decrypt[5:]
|
||||
|
||||
cab = await self.data.arcade.get_machine(netid)
|
||||
if cab:
|
||||
arcade = await self.data.arcade.get_arcade(cab['id'])
|
||||
if not arcade:
|
||||
self.logger.error(f"Failed to get arcade with id {cab['id']}")
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
resp.AREA_0 = arcade["region_id"] or AllnetJapanRegionId.AICHI.name
|
||||
resp.AREA_0_EN = arcade["region_id"] or AllnetJapanRegionId.AICHI.name
|
||||
resp.AREA_FULL_0 = arcade["region_id"] or AllnetJapanRegionId.AICHI.name
|
||||
resp.AREA_FULL_0_EN = arcade["region_id"] or AllnetJapanRegionId.AICHI.name
|
||||
|
||||
resp.AREA_1 = arcade["country"] or cab['country'] or AllnetCountryCode.JAPAN.value
|
||||
resp.AREA_1_EN = arcade["country"] or cab['country'] or AllnetCountryCode.JAPAN.value
|
||||
resp.AREA_FULL_1 = arcade["country"] or cab['country'] or AllnetCountryCode.JAPAN.value
|
||||
resp.AREA_FULL_1_EN = arcade["country"] or cab['country'] or AllnetCountryCode.JAPAN.value
|
||||
|
||||
resp.AREA_2 = arcade["city"] if arcade["city"] else ""
|
||||
resp.AREA_2_EN = arcade["city"] if arcade["city"] else ""
|
||||
resp.AREA_FULL_2 = arcade["city"] if arcade["city"] else ""
|
||||
resp.AREA_FULL_2_EN = arcade["city"] if arcade["city"] else ""
|
||||
|
||||
resp.AREA_3 = ""
|
||||
resp.AREA_3_EN = ""
|
||||
resp.AREA_FULL_3 = ""
|
||||
resp.AREA_FULL_3_EN = ""
|
||||
|
||||
resp.PREFECTURE_ID = arcade['region_id']
|
||||
resp.COUNTRY_CD = arcade['country'] or cab['country'] or AllnetCountryCode.JAPAN.value
|
||||
resp.PLACE_ID = req.placeId if req.placeId else f"{arcade['country'] or cab['country'] or AllnetCountryCode.JAPAN.value}{arcade['id']:04X}"
|
||||
resp.SHOP_NAME = arcade['name']
|
||||
resp.SHOP_NAME_EN = arcade['name']
|
||||
resp.SHOP_NICKNAME = arcade['nickname']
|
||||
resp.SHOP_NICKNAME_EN = arcade['nickname']
|
||||
|
||||
elif self.config.server.allow_unregistered_serials:
|
||||
self.logger.info(f"Allow unknown serial {netid} ({sn_decrypt}) to auth")
|
||||
|
||||
else:
|
||||
self.logger.warning(f'Auth failed for NetID {netid}')
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
self.logger.debug(f"Mucha response {vars(resp)}")
|
||||
|
||||
return PlainTextResponse(self.mucha_postprocess(vars(resp)))
|
||||
|
||||
async def handle_updatecheck(self, request: Request) -> bytes:
|
||||
bod = await request.body()
|
||||
req_dict = self.mucha_preprocess(bod)
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
|
||||
if req_dict is None:
|
||||
self.logger.error(
|
||||
f"Error processing mucha request {bod}"
|
||||
)
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
req = MuchaUpdateRequest(req_dict)
|
||||
self.logger.info(f"Updatecheck request from {req.serialNum} ({client_ip}) for {req.gameVer}")
|
||||
self.logger.debug(f"Mucha request {vars(req)}")
|
||||
self.logger.info(f"Boardauth request from {client_ip} for {req.gameVer}")
|
||||
|
||||
if req.gameCd not in self.mucha_registry:
|
||||
self.logger.warning(f"Unknown gameCd {req.gameCd}")
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
self.logger.warn(f"Unknown gameCd {req.gameCd}")
|
||||
return b""
|
||||
|
||||
resp = MuchaUpdateResponse(req.gameVer, f"{self.config.server.hostname}{':' + str(self.config.server.port) if not self.config.server.is_using_proxy else ''}")
|
||||
# TODO: Decrypt S/N
|
||||
|
||||
resp = MuchaAuthResponse(
|
||||
f"{self.config.mucha.hostname}{':' + str(self.config.allnet.port) if self.config.server.is_develop else ''}"
|
||||
)
|
||||
|
||||
self.logger.debug(f"Mucha response {vars(resp)}")
|
||||
|
||||
return PlainTextResponse(self.mucha_postprocess(vars(resp)))
|
||||
return self.mucha_postprocess(vars(resp))
|
||||
|
||||
async def handle_dlstate(self, request: Request) -> bytes:
|
||||
bod = await request.body()
|
||||
req_dict = self.mucha_preprocess(bod)
|
||||
def handle_updatecheck(self, request: Request, _: Dict) -> bytes:
|
||||
req_dict = self.mucha_preprocess(request.content.getvalue())
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
|
||||
if req_dict is None:
|
||||
self.logger.error(
|
||||
f"Error processing mucha request {bod}"
|
||||
f"Error processing mucha request {request.content.getvalue()}"
|
||||
)
|
||||
return PlainTextResponse("RESULTS=000")
|
||||
|
||||
req = MuchaDownloadStateRequest(req_dict)
|
||||
self.logger.info(f"DownloadState request from {req.serialNum} ({client_ip}) for {req.gameCd} -> {req.updateVer}")
|
||||
self.logger.debug(f"request {vars(req)}")
|
||||
return PlainTextResponse("RESULTS=001")
|
||||
return b""
|
||||
|
||||
req = MuchaUpdateRequest(req_dict)
|
||||
self.logger.debug(f"Mucha request {vars(req)}")
|
||||
self.logger.info(f"Updatecheck request from {client_ip} for {req.gameVer}")
|
||||
|
||||
if req.gameCd not in self.mucha_registry:
|
||||
self.logger.warn(f"Unknown gameCd {req.gameCd}")
|
||||
return b""
|
||||
|
||||
resp = MuchaUpdateResponseStub(req.gameVer)
|
||||
|
||||
self.logger.debug(f"Mucha response {vars(resp)}")
|
||||
|
||||
return self.mucha_postprocess(vars(resp))
|
||||
|
||||
def mucha_preprocess(self, data: bytes) -> Optional[Dict]:
|
||||
try:
|
||||
@ -192,17 +111,19 @@ class MuchaServlet:
|
||||
|
||||
return ret
|
||||
|
||||
except Exception:
|
||||
except:
|
||||
self.logger.error(f"Error processing mucha request {data}")
|
||||
return None
|
||||
|
||||
def mucha_postprocess(self, data: dict) -> Optional[bytes]:
|
||||
try:
|
||||
urlencode = "&".join(f"{k}={v}" for k, v in data.items())
|
||||
urlencode = ""
|
||||
for k, v in data.items():
|
||||
urlencode += f"{k}={v}&"
|
||||
|
||||
return urlencode.encode()
|
||||
|
||||
except Exception:
|
||||
except:
|
||||
self.logger.error("Error processing mucha response")
|
||||
return None
|
||||
|
||||
@ -229,7 +150,7 @@ class MuchaAuthResponse:
|
||||
self.RESULTS = "001"
|
||||
self.AUTH_INTERVAL = "86400"
|
||||
self.SERVER_TIME = datetime.strftime(datetime.now(), "%Y%m%d%H%M")
|
||||
self.SERVER_TIME_UTC = datetime.strftime(datetime.now(pytz.UTC), "%Y%m%d%H%M")
|
||||
self.UTC_SERVER_TIME = datetime.strftime(datetime.now(pytz.UTC), "%Y%m%d%H%M")
|
||||
|
||||
self.CHARGE_URL = f"https://{mucha_url}/charge/"
|
||||
self.FILE_URL = f"https://{mucha_url}/file/"
|
||||
@ -281,121 +202,22 @@ class MuchaUpdateRequest:
|
||||
|
||||
class MuchaUpdateResponse:
|
||||
def __init__(self, game_ver: str, mucha_url: str) -> None:
|
||||
self.RESULTS = "001"
|
||||
self.EXE_VER = game_ver
|
||||
|
||||
self.RESULTS = "001"
|
||||
self.UPDATE_VER_1 = game_ver
|
||||
self.UPDATE_URL_1 = f"http://{mucha_url}/updUrl1/"
|
||||
self.UPDATE_SIZE_1 = "20"
|
||||
|
||||
self.CHECK_CRC_1 = "0000000000000000"
|
||||
self.CHECK_URL_1 = f"http://{mucha_url}/checkUrl/"
|
||||
self.CHECK_SIZE_1 = "20"
|
||||
|
||||
self.UPDATE_URL_1 = f"https://{mucha_url}/updUrl1/"
|
||||
self.UPDATE_SIZE_1 = "0"
|
||||
self.UPDATE_CRC_1 = "0000000000000000"
|
||||
self.CHECK_URL_1 = f"https://{mucha_url}/checkUrl/"
|
||||
self.EXE_VER_1 = game_ver
|
||||
self.INFO_SIZE_1 = "0"
|
||||
self.COM_SIZE_1 = "0"
|
||||
self.COM_TIME_1 = "0"
|
||||
self.LAN_INFO_SIZE_1 = "0"
|
||||
|
||||
self.USER_ID = ""
|
||||
self.PASSWORD = ""
|
||||
|
||||
"""
|
||||
RESULTS
|
||||
EXE_VER
|
||||
|
||||
UPDATE_VER_%d
|
||||
UPDATE_URL_%d
|
||||
UPDATE_SIZE_%d
|
||||
|
||||
CHECK_CRC_%d
|
||||
CHECK_URL_%d
|
||||
CHECK_SIZE_%d
|
||||
|
||||
INFO_SIZE_1
|
||||
COM_SIZE_1
|
||||
COM_TIME_1
|
||||
LAN_INFO_SIZE_1
|
||||
|
||||
USER_ID
|
||||
PASSWORD
|
||||
"""
|
||||
class MuchaUpdateResponseStub:
|
||||
def __init__(self, game_ver: str) -> None:
|
||||
self.RESULTS = "001"
|
||||
self.UPDATE_VER_1 = game_ver
|
||||
|
||||
class MuchaDownloadStateRequest:
|
||||
def __init__(self, request: Dict) -> None:
|
||||
self.gameCd = request.get("gameCd", "")
|
||||
self.updateVer = request.get("updateVer", "")
|
||||
self.serialNum = request.get("serialNum", "")
|
||||
self.fileSize = request.get("fileSize", "")
|
||||
self.compFileSize = request.get("compFileSize", "")
|
||||
self.boardId = request.get("boardId", "")
|
||||
self.placeId = request.get("placeId", "")
|
||||
self.storeRouterIp = request.get("storeRouterIp", "")
|
||||
|
||||
class MuchaDownloadErrorRequest:
|
||||
def __init__(self, request: Dict) -> None:
|
||||
self.gameCd = request.get("gameCd", "")
|
||||
self.updateVer = request.get("updateVer", "")
|
||||
self.serialNum = request.get("serialNum", "")
|
||||
self.downloadUrl = request.get("downloadUrl", "")
|
||||
self.errCd = request.get("errCd", "")
|
||||
self.errMessage = request.get("errMessage", "")
|
||||
self.boardId = request.get("boardId", "")
|
||||
self.placeId = request.get("placeId", "")
|
||||
self.storeRouterIp = request.get("storeRouterIp", "")
|
||||
|
||||
class MuchaRegiAuthRequest:
|
||||
def __init__(self, request: Dict) -> None:
|
||||
self.gameCd = request.get("gameCd", "")
|
||||
self.serialNum = request.get("serialNum", "") # Encrypted
|
||||
self.countryCd = request.get("countryCd", "")
|
||||
self.registrationCd = request.get("registrationCd", "")
|
||||
self.sendDate = request.get("sendDate", "")
|
||||
self.useToken = request.get("useToken", "")
|
||||
self.allToken = request.get("allToken", "")
|
||||
self.placeId = request.get("placeId", "")
|
||||
self.storeRouterIp = request.get("storeRouterIp", "")
|
||||
|
||||
class MuchaRegiAuthResponse:
|
||||
def __init__(self) -> None:
|
||||
self.RESULTS = "001" # 001 = success, 099, 098, 097 = fail, others = fail
|
||||
self.ALL_TOKEN = "0" # Encrypted
|
||||
self.ADD_TOKEN = "0" # Encrypted
|
||||
|
||||
class MuchaTokenStateRequest:
|
||||
def __init__(self, request: Dict) -> None:
|
||||
self.gameCd = request.get("gameCd", "")
|
||||
self.serialNum = request.get("serialNum", "")
|
||||
self.countryCd = request.get("countryCd", "")
|
||||
self.useToken = request.get("useToken", "")
|
||||
self.allToken = request.get("allToken", "")
|
||||
self.placeId = request.get("placeId", "")
|
||||
self.storeRouterIp = request.get("storeRouterIp", "")
|
||||
|
||||
class MuchaTokenStateResponse:
|
||||
def __init__(self) -> None:
|
||||
self.RESULTS = "001"
|
||||
|
||||
class MuchaTokenMarginStateRequest:
|
||||
def __init__(self, request: Dict) -> None:
|
||||
self.gameCd = request.get("gameCd", "")
|
||||
self.serialNum = request.get("serialNum", "")
|
||||
self.countryCd = request.get("countryCd", "")
|
||||
self.placeId = request.get("placeId", "")
|
||||
self.limitLowerToken = request.get("limitLowerToken", 0)
|
||||
self.limitUpperToken = request.get("limitUpperToken", 0)
|
||||
self.settlementMonth = request.get("settlementMonth", 0)
|
||||
|
||||
class MuchaTokenMarginStateResponse:
|
||||
def __init__(self) -> None:
|
||||
self.RESULTS = "001"
|
||||
self.LIMIT_LOWER_TOKEN = 0
|
||||
self.LIMIT_UPPER_TOKEN = 0
|
||||
self.LAST_SETTLEMENT_MONTH = 0
|
||||
self.LAST_LIMIT_LOWER_TOKEN = 0
|
||||
self.LAST_LIMIT_UPPER_TOKEN = 0
|
||||
self.SETTLEMENT_MONTH = 0
|
||||
|
@ -1,105 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
{% if arcade is defined %}
|
||||
<h1>{{ arcade.name }}</h1>
|
||||
<h2>Assigned Machines</h2>
|
||||
{% if success is defined and success == 3 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Cab added successfully
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if success is defined and success == 1 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Info Updated
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "core/templates/widgets/err_banner.jinja" %}
|
||||
<ul style="font-size: 20px;">
|
||||
{% for c in cablst %}
|
||||
<li><a href="/cab/{{ c.id }}">{{ c.serial }}</a> ({{ c.game if c.game else "Any" }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
Info
|
||||
<form style="max-width: 50%;" action="/shop/{{ arcade.id }}/info.update" method="post" id="shop_info">
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" maxlength="255" value="{{ arcade.name if arcade.name is not none else "" }}">
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="nickname" class="form-label">Nickname</label>
|
||||
<input type="text" class="form-control" id="nickname" name="nickname" maxlength="255" value="{{ arcade.nickname if arcade.nickname is not none else "" }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="country" class="form-label">Country</label>
|
||||
<select id="country" name="country" class="form-select bg-dark text-white">
|
||||
<option value="JPN" {{ 'selected' if arcade.country == 'JPN' else ''}}>Japan</option>
|
||||
<option value="USA" {{ 'selected' if arcade.country == 'USA' else ''}}>USA</option>
|
||||
<option value="HKG" {{ 'selected' if arcade.country == 'HKG' else ''}}>Hong Kong</option>
|
||||
<option value="SGP" {{ 'selected' if arcade.country == 'SGP' else ''}}>Singapore</option>
|
||||
<option value="KOR" {{ 'selected' if arcade.country == 'KOR' else ''}}>South Korea</option>
|
||||
<option value="TWN" {{ 'selected' if arcade.country == 'TWN' else ''}}>Taiwan</option>
|
||||
<option value="CHN" {{ 'selected' if arcade.country == 'CHN' else ''}}>China</option>
|
||||
<option value="AUS" {{ 'selected' if arcade.country == 'AUS' else ''}}>Australia</option>
|
||||
<option value="IDN" {{ 'selected' if arcade.country == 'IDN' else ''}}>Indonesia</option>
|
||||
<option value="MMR" {{ 'selected' if arcade.country == 'MMR' else ''}}>Myanmar</option>
|
||||
<option value="MYS" {{ 'selected' if arcade.country == 'MYS' else ''}}>Malaysia</option>
|
||||
<option value="NZL" {{ 'selected' if arcade.country == 'NZL' else ''}}>New Zealand</option>
|
||||
<option value="PHL" {{ 'selected' if arcade.country == 'PHL' else ''}}>Philippines</option>
|
||||
<option value="THA" {{ 'selected' if arcade.country == 'THA' else ''}}>Thailand</option>
|
||||
<option value="VNM" {{ 'selected' if arcade.country == 'VNM' else ''}}>Vietnam</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="region1" class="form-label">Region 1</label>
|
||||
<input type="text" class="form-control" id="region1" name="region1" maxlength="255" value="{{ arcade.state if arcade.state is not none else "" }}">
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="region2" class="form-label">Region 2</label>
|
||||
<input type="text" class="form-control" id="region2" name="region2" maxlength="255" value="{{ arcade.city if arcade.city is not none else "" }}">
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="tz" class="form-label">Timezone</label>
|
||||
<input type="text" class="form-control" id="tz" name="tz" placeholder="+09:00" maxlength="255" value="{{ arcade.timezone if arcade.timezone is not none else "" }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="ip" class="form-label">VPN IP</label>
|
||||
<input type="text" class="form-control" id="ip" name="ip" maxlength="39" value="{{ arcade.ip if arcade.ip is not none else "" }}">
|
||||
</div>
|
||||
</div>
|
||||
{% if can_edit %}
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<input type="submit" value="Update" class="btn btn-primary">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% if is_owner or is_acmod %}
|
||||
<br>
|
||||
<h2>Arcade Managers <button type="button" class="btn btn-success">Add</button></h2>
|
||||
<ul style="font-size: 20px;">
|
||||
{% for u in managers %}
|
||||
<li>{{ u.name }}:
|
||||
<label for="is_view_{{ u.user }}" class="form-label">View Arcade</label>
|
||||
<input type="checkbox" class="form-control-check" id="is_view_{{ u.user }}" name="is_view" {{ 'checked' if u.is_view else ''}}> |
|
||||
<label for="is_bookkeep_{{ u.user }}" class="form-label">View Bookkeeping</label>
|
||||
<input type="checkbox" class="form-control-check" id="is_bookkeep_{{ u.user }}" name="is_bookkeep" {{ 'checked' if u.is_bookkeep else ''}}> |
|
||||
<label for="is_edit_{{ u.user }}" class="form-label">Edit Arcade</label>
|
||||
<input type="checkbox" class="form-control-check" id="is_edit_{{ u.user }}" name="is_edit" {{ 'checked' if u.is_edit else ''}}> |
|
||||
<label for="is_owner_{{ u.user }}" class="form-label">Owner</label>
|
||||
<input type="checkbox" class="form-control-check" id="is_owner_{{ u.user }}" name="is_owner" {{ 'checked' if u.is_owner else ''}}> |
|
||||
<button type="submit" class="btn btn-primary">Update</button>
|
||||
<button type="button" class="btn btn-danger">Delete</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<h3>Arcade Not Found</h3>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
@ -1,32 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>Gate</h1>
|
||||
{% include "core/templates/widgets/err_banner.jinja" %}
|
||||
<style>
|
||||
/* Chrome, Safari, Edge, Opera */
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Firefox */
|
||||
input[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
</style>
|
||||
<form id="login" style="max-width: 240px; min-width: 15%;" action="/gate/gate.login" method="post">
|
||||
<div class="form-group row">
|
||||
<label for="access_code">Access Code or Username</label><br>
|
||||
<input form="login" class="form-control" name="access_code" id="access_code" placeholder="00000000000000000000" maxlength="20" required aria-describedby="access_code_help">
|
||||
<div id="access_code_help" class="form-text">20 Digit access code from a card registered to your account, or your account username. (NOT your username from a game!)</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="passwd">Password</label><br>
|
||||
<input id="passwd" class="form-control" name="passwd" type="password" placeholder="password" aria-describedby="passwd_help">
|
||||
<div id="passwd_help" class="form-text">Leave blank if registering for the webui. Your card must have been used on a game connected to this server to register.</div>
|
||||
</div>
|
||||
<p></p>
|
||||
<input id="submit" class="btn btn-primary" style="display: block; margin: 0 auto;" form="login" type="submit" value="Login">
|
||||
</form>
|
||||
{% endblock content %}
|
@ -1,109 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
<script type="text/javascript">
|
||||
function swap_ota() {
|
||||
let is_cab = document.getElementById("is_cab").checked;
|
||||
let txt_ota = document.getElementById("ota_channel");
|
||||
|
||||
cbx_ota.disabled = !is_cab;
|
||||
}
|
||||
</script>
|
||||
<h1>Machine: {{machine.serial}}</h1>
|
||||
<h3>Arcade: <a href=/shop/{{ arcade.id }}>{{ arcade.name }}</a>{% if is_acmod %} <button class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#reassign_modal">Reassign</button>{% endif %}</h3>
|
||||
{% include "core/templates/widgets/err_banner.jinja" %}
|
||||
{% if success is defined and success == 1 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Info Updated
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if success is defined and success == 2 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Machine successfully reassigned
|
||||
</div>
|
||||
{% endif %}
|
||||
Info
|
||||
<form style="max-width: 50%;" action="/cab/{{ machine.id }}/info.update" method="post" id="mech_info">
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="game" class="form-label">Game</label>
|
||||
<input type="text" class="form-control" id="game" name="game" placeholder="SXXX" maxlength="4" value="{{ machine.game if machine.game is not none else "" }}">
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="country" class="form-label">Country Override</label>
|
||||
<select id="country" name="country" class="form-select bg-dark text-white">
|
||||
<option value="" {{ 'selected' if machine.country is none else ''}}>Same As Arcade</option>
|
||||
<option value="JPN" {{ 'selected' if machine.country == 'JPN' else ''}}>Japan</option>
|
||||
<option value="USA" {{ 'selected' if machine.country == 'USA' else ''}}>USA</option>
|
||||
<option value="HKG" {{ 'selected' if machine.country == 'HKG' else ''}}>Hong Kong</option>
|
||||
<option value="SGP" {{ 'selected' if machine.country == 'SGP' else ''}}>Singapore</option>
|
||||
<option value="KOR" {{ 'selected' if machine.country == 'KOR' else ''}}>South Korea</option>
|
||||
<option value="TWN" {{ 'selected' if machine.country == 'TWN' else ''}}>Taiwan</option>
|
||||
<option value="CHN" {{ 'selected' if machine.country == 'CHN' else ''}}>China</option>
|
||||
<option value="AUS" {{ 'selected' if machine.country == 'AUS' else ''}}>Australia</option>
|
||||
<option value="IDN" {{ 'selected' if machine.country == 'IDN' else ''}}>Indonesia</option>
|
||||
<option value="MMR" {{ 'selected' if machine.country == 'MMR' else ''}}>Myanmar</option>
|
||||
<option value="MYS" {{ 'selected' if machine.country == 'MYS' else ''}}>Malaysia</option>
|
||||
<option value="NZL" {{ 'selected' if machine.country == 'NZL' else ''}}>New Zealand</option>
|
||||
<option value="PHL" {{ 'selected' if machine.country == 'PHL' else ''}}>Philippines</option>
|
||||
<option value="THA" {{ 'selected' if machine.country == 'THA' else ''}}>Thailand</option>
|
||||
<option value="VNM" {{ 'selected' if machine.country == 'VNM' else ''}}>Vietnam</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<label for="tz" class="form-label">Timezone Override</label>
|
||||
<input type="text" class="form-control" id="tz" name="tz" placeholder="+09:00" maxlength="6" value="{{ machine.timezone if machine.timezone is not none else "" }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<input type="checkbox" class="form-control-check" id="is_cab" name="is_cab" {{ 'checked' if machine.is_cab else ''}} onchange="swap_ota()">
|
||||
<label for="is_cab" class="form-label">Real Cabinet</label>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
<input type="text" class="form-control-check" id="ota_channel" name="ota_channel" value={{ machine.ota_channel }} {{ 'disabled' if not machine.is_cab else '' }}>
|
||||
<label for="ota_channel" class="form-label">OTA Update Channel</label>
|
||||
</div>
|
||||
<div class="col mb-3">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<label for="memo" class="form-label">Memo</label>
|
||||
<input type="text" class="form-control" id="memo" name="memo" maxlength="255" value="{{ machine.memo if machine.memo is not none else "" }}">
|
||||
</div>
|
||||
</div>
|
||||
{% if can_edit %}
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<input type="submit" value="Update" class="btn btn-primary">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% if is_acmod %}
|
||||
<form id="frm_reassign" method="post" action="/cab/{{ machine.id }}/reassign" style="outline: 0px;">
|
||||
<div class="modal" tabindex="-1" id="reassign_modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Reassign {{ machine.serial }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>This will reassign this cabinet from the current arcade "{{ arcade.name }}" to the arcade who's ID you enter below.</p>
|
||||
<label for="new_arcade" class="form-label">New Arcade</label>
|
||||
<input type="text" class="form-control" id="new_arcade" name="new_arcade" value="{{ arcade.id }}">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
<script type="text/javascript">
|
||||
swap_ota();
|
||||
</script>
|
||||
{% endblock content %}
|
@ -1,197 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>System Management</h1>
|
||||
{% if error is defined %}
|
||||
{% include "core/templates/widgets/err_banner.jinja" %}
|
||||
{% endif %}
|
||||
<h2>Search</h2>
|
||||
<div class="row" id="rowForm">
|
||||
{% if "{:08b}".format(sesh.permissions)[6] == "1" %}
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="usrLookup" name="usrLookup" action="/sys/lookup.user" class="form-inline">
|
||||
<h3>User Search</h3>
|
||||
<div class="form-group">
|
||||
<label for="usrId">User ID</label>
|
||||
<input type="number" class="form-control" id="usrId" name="usrId">
|
||||
</div>
|
||||
OR
|
||||
<div class="form-group">
|
||||
<label for="usrName">Username</label>
|
||||
<input type="text" class="form-control" id="usrName" name="usrName">
|
||||
</div>
|
||||
OR
|
||||
<div class="form-group">
|
||||
<label for="usrEmail">Email address</label>
|
||||
<input type="email" class="form-control" id="usrEmail" name="usrEmail">
|
||||
</div>
|
||||
OR
|
||||
<div class="form-group">
|
||||
<label for="usrAc">Access Code</label>
|
||||
<input type="text" class="form-control" id="usrAc" name="usrAc" maxlength="20" placeholder="00000000000000000000">
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if "{:08b}".format(sesh.permissions)[5] == "1" %}
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="shopLookup" name="shopLookup" action="/sys/lookup.shop" class="form-inline">
|
||||
<h3>Shop search</h3>
|
||||
<div class="form-group">
|
||||
<label for="shopId">Shop ID</label>
|
||||
<input type="number" class="form-control" id="shopId" name="shopId">
|
||||
</div>
|
||||
OR
|
||||
<div class="form-group">
|
||||
<label for="serialNum">Serial Number</label>
|
||||
<input type="text" class="form-control" id="serialNum" name="serialNum" maxlength="15">
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<a href="/sys/logs"><button class="btn btn-primary">Event Logs</button></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row" id="rowResult" style="margin: 10px;">
|
||||
{% if "{:08b}".format(sesh.permissions)[6] == "1" %}
|
||||
<div id="userSearchResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% for usr in usrlist %}
|
||||
<a href=/user/{{ usr.id }}><pre>{{ usr.username if usr.username is not none else "<i>No Name Set</i>"}}</pre></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if "{:08b}".format(sesh.permissions)[5] == "1" %}
|
||||
<div id="shopSearchResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% for shop in shoplist %}
|
||||
<a href="/shop/{{ shop.id }}"><pre>{{ shop.name if shop.name else "<i>No Name Set</i>"}}</pre></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h2>Add</h2>
|
||||
<div class="row" id="rowAdd">
|
||||
{% if "{:08b}".format(sesh.permissions)[6] == "1" %}
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="usrAdd" name="usrAdd" action="/sys/add.user" class="form-inline" method="POST">
|
||||
<h3>Add User</h3>
|
||||
<div class="form-group">
|
||||
<label for="usrName">Username</label>
|
||||
<input type="text" class="form-control" id="usrName" name="usrName">
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="usrEmail">Email address</label>
|
||||
<input type="email" class="form-control" id="usrEmail" name="usrEmail" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="usrPerm">Permission Level</label>
|
||||
<input type="number" class="form-control" id="usrPerm" name="usrPerm" value="1">
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="cardAdd" name="cardAdd" action="/sys/add.card" class="form-inline" method="POST">
|
||||
<h3>Add Card</h3>
|
||||
<div class="form-group">
|
||||
<label for="cardUsr">User ID</label>
|
||||
<input type="number" class="form-control" id="cardUsr" name="cardUsr" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="cardAc">Access Code</label>
|
||||
<input type="text" class="form-control" id="cardAc" name="cardAc" maxlength="20" placeholder="00000000000000000000" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="cardIdm">IDm/Chip ID</label>
|
||||
<input type="text" class="form-control" id="cardIdm" name="cardIdm" disabled>
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if "{:08b}".format(sesh.permissions)[5] == "1" %}
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="shopAdd" name="shopAdd" action="/sys/add.shop" class="form-inline" method="POST">
|
||||
<h3>Add Shop</h3>
|
||||
<div class="form-group">
|
||||
<label for="shopName">Name</label>
|
||||
<input type="text" class="form-control" id="shopName" name="shopName">
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="shopCountry">Country Code</label>
|
||||
<input type="text" class="form-control" id="shopCountry" name="shopCountry" maxlength="3" placeholder="JPN">
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<label for="shopIp">VPN IP</label>
|
||||
<input type="text" class="form-control" id="shopIp" name="shopIp">
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<label for="shopOwner">Owner User ID</label>
|
||||
<input type="text" class="form-control" id="shopOwner" name="shopOwner">
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-sm-6" style="max-width: 25%;">
|
||||
<form id="cabAdd" name="cabAdd" action="/sys/add.cab" class="form-inline" method="POST">
|
||||
<h3>Add Machine</h3>
|
||||
<div class="form-group">
|
||||
<label for="cabShop">Shop ID</label>
|
||||
<input type="number" class="form-control" id="cabShop" name="cabShop" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<label for="cabSerial">Serial</label>
|
||||
<input type="text" class="form-control" id="cabSerial" name="cabSerial">
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<label for="cabGame">Game Code</label>
|
||||
<input type="text" class="form-control" id="cabGame" name="cabGame" maxlength="4" placeholder="SXXX">
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row" id="rowAddResult" style="margin: 10px;">
|
||||
{% if "{:08b}".format(sesh.permissions)[6] == "1" %}
|
||||
<div id="userAddResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% if usradd is defined %}
|
||||
<pre>Added user {{ usradd.username if usradd.username is not none else "with no name"}} with id {{usradd.id}} and password {{ usradd.password }}</pre>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="cardAddResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% if cardadd is defined %}
|
||||
<pre>Added {{ cardadd.access_code }} with id {{cardadd.id}} to user {{ cardadd.user }}</pre>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if "{:08b}".format(sesh.permissions)[5] == "1" %}
|
||||
<div id="shopAddResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% if shopadd is defined %}
|
||||
<pre>Added Shop {{ shopadd.id }}</pre></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="cabAddResult" class="col-sm-6" style="max-width: 25%;">
|
||||
{% if cabadd is defined %}
|
||||
<pre>Added Machine {{ cabadd.id }} with serial {{ cabadd.serial }}</pre></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock content %}
|
@ -1,202 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
<h1>Event Logs</h1>
|
||||
<table class="table table-dark table-striped-columns" id="tbl_events">
|
||||
<caption>Viewing last 100 logs</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Severity</th>
|
||||
<th>Timestamp</th>
|
||||
<th>System</th>
|
||||
<th>Name</th>
|
||||
<th>User</th>
|
||||
<th>Arcade</th>
|
||||
<th>Machine</th>
|
||||
<th>Game</th>
|
||||
<th>Version</th>
|
||||
<th>Message</th>
|
||||
<th>Params</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% if events is not defined or events|length == 0 %}
|
||||
<tr>
|
||||
<td colspan="11" style="text-align:center"><i>No Events</i></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
<div id="div_tbl_ctrl">
|
||||
<select id="sel_per_page" onchange="update_tbl()">
|
||||
<option value="10" selected>10</option>
|
||||
<option value="25">25</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
</select>
|
||||
|
||||
<button class="btn btn-primary" id="btn_prev" disabled onclick="chg_page(-1)"><<</button>
|
||||
<button class="btn btn-primary" id="btn_next" onclick="chg_page(1)">>></button>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
{% if events is defined %}
|
||||
const TBL_DATA = {{events}};
|
||||
{% else %}
|
||||
const TBL_DATA = [];
|
||||
{% endif %}
|
||||
|
||||
var per_page = 0;
|
||||
var page = 0;
|
||||
|
||||
function update_tbl() {
|
||||
if (TBL_DATA.length == 0) {
|
||||
document.getElementById("btn_next").disabled = true;
|
||||
document.getElementById("btn_prev").disabled = true;
|
||||
return;
|
||||
}
|
||||
var tbl = document.getElementById("tbl_events");
|
||||
|
||||
for (var i = 0; i < per_page; i++) {
|
||||
try{
|
||||
tbl.deleteRow(1);
|
||||
} catch {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
per_page = document.getElementById("sel_per_page").value;
|
||||
|
||||
if (per_page >= TBL_DATA.length) {
|
||||
page = 0;
|
||||
document.getElementById("btn_next").disabled = true;
|
||||
document.getElementById("btn_prev").disabled = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < per_page; i++) {
|
||||
let off = (page * per_page) + i;
|
||||
if (off >= TBL_DATA.length) {
|
||||
if (page != 0) {
|
||||
document.getElementById("btn_next").disabled = true;
|
||||
document.getElementById("btn_prev").disabled = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var data = TBL_DATA[off];
|
||||
var row = tbl.insertRow(i + 1);
|
||||
var cell_severity = row.insertCell(0);
|
||||
switch (data.severity) {
|
||||
case 10:
|
||||
cell_severity.innerHTML = "DEBUG";
|
||||
row.classList.add("table-success");
|
||||
break;
|
||||
case 20:
|
||||
cell_severity.innerHTML = "INFO";
|
||||
row.classList.add("table-info");
|
||||
break;
|
||||
case 30:
|
||||
cell_severity.innerHTML = "WARN";
|
||||
row.classList.add("table-warning");
|
||||
break;
|
||||
case 40:
|
||||
cell_severity.innerHTML = "ERROR";
|
||||
row.classList.add("table-danger");
|
||||
break;
|
||||
case 50:
|
||||
cell_severity.innerHTML = "CRITICAL";
|
||||
row.classList.add("table-danger");
|
||||
break;
|
||||
default:
|
||||
cell_severity.innerHTML = "---";
|
||||
row.classList.add("table-primary");
|
||||
break;
|
||||
}
|
||||
|
||||
var cell_ts = row.insertCell(1);
|
||||
cell_ts.innerHTML = data.when_logged;
|
||||
|
||||
var cell_mod = row.insertCell(2);
|
||||
cell_mod.innerHTML = data.system;
|
||||
|
||||
var cell_name = row.insertCell(3);
|
||||
cell_name.innerHTML = data.type;
|
||||
|
||||
var cell_usr = row.insertCell(4);
|
||||
if (data.user == 'NONE') {
|
||||
cell_usr.innerHTML = "---";
|
||||
} else {
|
||||
cell_usr.innerHTML = "<a href=\"/user/" + data.user + "\">" + data.user + "</a>";
|
||||
}
|
||||
|
||||
var cell_arcade = row.insertCell(5);
|
||||
if (data.arcade == 'NONE') {
|
||||
cell_arcade.innerHTML = "---";
|
||||
} else {
|
||||
cell_arcade.innerHTML = "<a href=\"/shop/" + data.arcade + "\">" + data.arcade + "</a>";
|
||||
}
|
||||
|
||||
var cell_machine = row.insertCell(6);
|
||||
if (data.arcade == 'NONE') {
|
||||
cell_machine.innerHTML = "---";
|
||||
} else {
|
||||
cell_machine.innerHTML = "<a href=\"/cab/" + data.machine + "\">" + data.machine + "</a>";
|
||||
}
|
||||
|
||||
var cell_game = row.insertCell(7);
|
||||
if (data.game == 'NONE') {
|
||||
cell_game.innerHTML = "---";
|
||||
} else {
|
||||
cell_game.innerHTML = data.game;
|
||||
}
|
||||
|
||||
var cell_version = row.insertCell(8);
|
||||
if (data.version == 'NONE') {
|
||||
cell_version.innerHTML = "---";
|
||||
} else {
|
||||
cell_version.innerHTML = data.version;
|
||||
}
|
||||
|
||||
var cell_msg = row.insertCell(9);
|
||||
if (data.message == '') {
|
||||
cell_msg.innerHTML = "---";
|
||||
} else {
|
||||
cell_msg.innerHTML = data.message;
|
||||
}
|
||||
|
||||
var cell_deets = row.insertCell(10);
|
||||
if (data.details == '{}') {
|
||||
cell_deets.innerHTML = "---";
|
||||
} else {
|
||||
cell_deets.innerHTML = data.details;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function chg_page(num) {
|
||||
var max_page = TBL_DATA.length / per_page;
|
||||
console.log(max_page);
|
||||
page = page + num;
|
||||
|
||||
|
||||
if (page > max_page && max_page >= 1) {
|
||||
page = max_page;
|
||||
document.getElementById("btn_next").disabled = true;
|
||||
document.getElementById("btn_prev").disabled = false;
|
||||
return;
|
||||
} else if (page < 0) {
|
||||
page = 0;
|
||||
document.getElementById("btn_next").disabled = false;
|
||||
document.getElementById("btn_prev").disabled = true;
|
||||
return;
|
||||
} else if (page == 0) {
|
||||
document.getElementById("btn_next").disabled = TBL_DATA.length == 0;
|
||||
document.getElementById("btn_prev").disabled = true;
|
||||
} else {
|
||||
document.getElementById("btn_next").disabled = false;
|
||||
document.getElementById("btn_prev").disabled = false;
|
||||
}
|
||||
|
||||
update_tbl();
|
||||
}
|
||||
|
||||
update_tbl();
|
||||
</script>
|
||||
{% endblock content %}
|
@ -1,204 +0,0 @@
|
||||
{% extends "core/templates/index.jinja" %}
|
||||
{% block content %}
|
||||
<script type="text/javascript">
|
||||
function toggle_new_name_form() {
|
||||
let frm = document.getElementById("new_name_form");
|
||||
let btn = document.getElementById("btn_toggle_form");
|
||||
|
||||
if (frm.style['display'] != "") {
|
||||
frm.style['display'] = "";
|
||||
frm.style['max-height'] = "";
|
||||
btn.innerText = "Cancel";
|
||||
} else {
|
||||
frm.style['display'] = "none";
|
||||
frm.style['max-height'] = "0px";
|
||||
btn.innerText = "Edit";
|
||||
}
|
||||
}
|
||||
function toggle_add_card_form() {
|
||||
let btn = document.getElementById("btn_add_card");
|
||||
let dv = document.getElementById("add_card_container")
|
||||
|
||||
if (dv.style['display'] != "") {
|
||||
btn.innerText = "Cancel";
|
||||
dv.style['display'] = "";
|
||||
} else {
|
||||
btn.innerText = "Add";
|
||||
dv.style['display'] = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function toggle_idm_disabled(is_disabled) {
|
||||
document.getElementById("btn_add_card");
|
||||
let dv = document.getElementById("add_card_container")
|
||||
|
||||
if (dv.style['display'] != "") {
|
||||
btn.innerText = "Cancel";
|
||||
dv.style['display'] = "";
|
||||
} else {
|
||||
btn.innerText = "Add";
|
||||
dv.style['display'] = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function prep_edit_form(access_code, chip_id, idm, card_type, u_memo, card_id) {
|
||||
ac = document.getElementById("card_edit_frm_access_code");
|
||||
cid = document.getElementById("card_edit_frm_chip_id");
|
||||
fidm = document.getElementById("card_edit_frm_idm");
|
||||
memo = document.getElementById("card_edit_frm_memo");
|
||||
|
||||
|
||||
document.getElementById("card_edit_frm_card_id").value = card_id;
|
||||
|
||||
if (chip_id == "None" || chip_id == undefined) {
|
||||
chip_id = ""
|
||||
}
|
||||
if (idm == "None" || idm == undefined) {
|
||||
idm = ""
|
||||
}
|
||||
if (u_memo == "None" || u_memo == undefined) {
|
||||
u_memo = ""
|
||||
}
|
||||
|
||||
ac.value = access_code;
|
||||
cid.value = chip_id;
|
||||
fidm.value = idm;
|
||||
memo.value = u_memo;
|
||||
|
||||
if (access_code.startsWith("3") || access_code.startsWith("010")) {
|
||||
cid.disabled = false;
|
||||
fidm.disabled = true;
|
||||
} else if (access_code.startsWith("5") || access_code.startsWith("0008")) {
|
||||
cid.disabled = true;
|
||||
fidm.disabled = false;
|
||||
} else {
|
||||
cid.disabled = true;
|
||||
fidm.disabled = true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<h1>Management for {{ username }} <button onclick="toggle_new_name_form()" class="btn btn-secondary" id="btn_toggle_form">Edit</button></h1>
|
||||
{% if error is defined %}
|
||||
{% include "core/templates/widgets/err_banner.jinja" %}
|
||||
{% endif %}
|
||||
{% if success is defined and success == 2 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Update successful
|
||||
</div>
|
||||
{% endif %}
|
||||
<form style="max-width: 33%; display: none; max-height: 0px;" action="/user/update.name" method="post" id="new_name_form">
|
||||
<div class="mb-3">
|
||||
<label for="new_name" class="form-label">New Nickname</label>
|
||||
<input type="text" class="form-control" id="new_name" name="new_name" aria-describedby="new_name_help">
|
||||
<div id="new_name_help" class="form-text">Must be 10 characters or less</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
<p></p>
|
||||
<h2>Cards <button class="btn btn-success" id="btn_add_card" onclick="toggle_add_card_form()">Add</button></h2>
|
||||
{% if success is defined and success == 3 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Card added successfully
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="add_card_container" style="display: none; max-width: 33%;">
|
||||
<form action="/user/add.card" method="post", id="frm_add_card">
|
||||
<div class="form-check">
|
||||
<input type="radio" id="card_add_frm_type_aicc" value="0" name="card_add_frm_type" aria-describedby="aicc_help" onclick="document.getElementById('card_add_frm_idm').disabled = false;">
|
||||
<label class="form-label" for="card_add_frm_type_aicc">AmusementIC</label>
|
||||
<div id="aicc_help" class="form-text">Starts with 5. If you don't have the IDm, use the 0008 access code shown in-game</div>
|
||||
<br>
|
||||
<input type="radio" id="card_add_frm_type_old" value="1" name="card_add_frm_type" aria-describedby="old_help" onclick="document.getElementById('card_add_frm_idm').disabled = true;">
|
||||
<label class="form-label" for="card_add_frm_type_old">Old Aime/Banapass</label>
|
||||
<div id="old_help" class="form-text">Starts with 010 (aime) or 3 (banapass)</div>
|
||||
</div>
|
||||
|
||||
<label class="form-label" for="card_add_frm_access_code">Access Code:</label>
|
||||
<input class="form-control" name="add_access_code" id="card_add_frm_access_code" maxlength="20" type="text" required aria-describedby="ac_help">
|
||||
<div id="ac_help" class="form-text">20 digit code on the back of the card.</div>
|
||||
<label class="form-label" for="card_add_frm_access_code">IDm:</label>
|
||||
<input class="form-control" name="add_idm" id="card_add_frm_idm" maxlength="16" type="text" aria-describedby="idm_help">
|
||||
<div id="idm_help" class="form-text">AmusementIC cards only! 16 hexidecimal digits, sometimes called the serial number, gotten by scanning the card with a reader.</div>
|
||||
<br>
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
<br>
|
||||
</div>
|
||||
{% if success is defined and success == 4 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Update successful
|
||||
</div>
|
||||
{% endif %}
|
||||
<ul style="font-size: 20px;">
|
||||
{% for c in cards %}
|
||||
<li>{{ c.access_code }} ({{ c.type if c.memo is none or not c.memo else c.memo }}): {{ c.status }} <button onclick="prep_edit_form('{{ c.access_code }}', '{{ c.chip_id}}', '{{ c.idm }}', '{{ c.type }}', '{{ c.memo }}', '{{ c.id }}')" data-bs-toggle="modal" data-bs-target="#card_edit" class="btn btn-secondary" id="btn_edit_card_{{ c.access_code }}">View</button> {% if c.status == 'Active'%}<button class="btn-warning btn">Lock</button>{% elif c.status == 'Locked' %}<button class="btn-warning btn">Unlock</button>{% endif %} <button class="btn-danger btn" {{ "disabled" if cards|length == 1 else ""}}>Delete</button></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h2>Reset Password</h2>
|
||||
{% if success is defined and success == 1 %}
|
||||
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
|
||||
Update successful
|
||||
</div>
|
||||
{% endif %}
|
||||
<form style="max-width: 33%;" action="/user/update.pw" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="current_pw" class="form-label">Current Password</label>
|
||||
<input type="password" class="form-control" id="current_pw" name="current_pw">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password1" class="form-label">New Password</label>
|
||||
<input type="password" class="form-control" id="password1" name="password1" aria-describedby="password_help">
|
||||
<div id="password_help" class="form-text">Password must be at least 10 characters long, contain an upper and lowercase character, number, and special character</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password2" class="form-label">Retype New Password</label>
|
||||
<input type="password" class="form-control" id="password2" name="password2">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
{% if arcades is defined and arcades|length > 0 %}
|
||||
<h2>Arcades you manage</h2>
|
||||
<ul>
|
||||
{% for a in arcades %}
|
||||
<li><h3><a href=/shop/{{a.id}}>{{ a.name }}</a></h3></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class="modal fade" id="card_edit" tabindex="-1" aria-labelledby="card_edit_label" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="card_edit_label">Card Information</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="/user/edit.card" method="post" id="frm_edit_card">
|
||||
<input type="hidden" readonly name="card_edit_frm_card_id" id="card_edit_frm_card_id">
|
||||
<label class="form-label" for="card_edit_frm_access_code">Access Code:</label>
|
||||
<input class="form-control-plaintext" readonly name="card_edit_frm_access_code" id="card_edit_frm_access_code" maxlength="20" type="text" required aria-describedby="ac_help">
|
||||
<div id="ac_help" class="form-text">20 digit code on the back of the card. If this is incorrect, contact a sysadmin.</div>
|
||||
|
||||
<label class="form-label" for="card_edit_frm_idm" id="card_edit_frm_idm_lbl">FeliCa IDm:</label>
|
||||
<input class="form-control-plaintext" aria-describedby="idm_help" name="add_felica_idm" id="card_edit_frm_idm" maxlength="16" type="text" readonly>
|
||||
<div id="idm_help" class="form-text">8 bytes that uniquly idenfites a FeliCa card. Obtained by reading the card with an NFC reader.</div>
|
||||
|
||||
<label class="form-label" for="card_edit_frm_chip_id" id="card_edit_frm_chip_id_lbl">Mifare UID:</label>
|
||||
<input class="form-control-plaintext" aria-describedby="chip_id_help" name="add_mifare_chip_id" id="card_edit_frm_chip_id" maxlength="8" type="text" readonly>
|
||||
<div id="chip_id_help" class="form-text">4 byte integer that uniquly identifies a Mifare card. Obtained by reading the card with an NFC reader.</div>
|
||||
|
||||
<label class="form-label" for="card_edit_frm_memo" id="card_edit_frm_memo_lbl">Memo:</label>
|
||||
<input class="form-control" aria-describedby="memo_help" name="add_memo" id="card_edit_frm_memo" maxlength="16" type="text">
|
||||
<div id="memo_help" class="form-text">Must be 16 characters or less.</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Update Memo</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
@ -1,38 +0,0 @@
|
||||
{% if error > 0 %}
|
||||
<div class="err-banner">
|
||||
<h3>Error</h3>
|
||||
{% if error == 1 %}
|
||||
Card not registered, or wrong password
|
||||
{% elif error == 2 %}
|
||||
Missing or malformed access code
|
||||
{% elif error == 3 %}
|
||||
Failed to create user
|
||||
{% elif error == 4 %}
|
||||
Required field not filled or invalid
|
||||
{% elif error == 5 %}
|
||||
Incorrect old password
|
||||
{% elif error == 6 %}
|
||||
Passwords don't match
|
||||
{% elif error == 7 %}
|
||||
New password not acceptable
|
||||
{% elif error == 8 %}
|
||||
New Nickname too long
|
||||
{% elif error == 9 %}
|
||||
You must be logged in to preform this action
|
||||
{% elif error == 10 %}
|
||||
Invalid serial number
|
||||
{% elif error == 11 %}
|
||||
Access Denied
|
||||
{% elif error == 12 %}
|
||||
Card already registered
|
||||
{% elif error == 13 %}
|
||||
AmusementIC Access Codes beginning with 5 must have IDm
|
||||
{% elif error == 14 %}
|
||||
Arcade does not exist
|
||||
{% elif error == 15 %}
|
||||
Some info failed to update
|
||||
{% else %}
|
||||
An unknown error occoured
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user