mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
Cleanup existing migrations
This commit is contained in:
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -38,4 +38,4 @@
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ https://python-poetry.org/docs/#installing-with-the-official-installer
|
||||
**_WARNING:_** Until poetry 1.8.0 version is released, poetry needs to be installed with the new non-package-mode feature branch:
|
||||
|
||||
```sh
|
||||
pipx install git+https://github.com/radoering/poetry.git@non-package-mode
|
||||
pipx install --suffix _npm git+https://github.com/radoering/poetry.git@non-package-mode
|
||||
```
|
||||
|
||||
More info: https://github.com/python-poetry/poetry/pull/8650
|
||||
@@ -44,9 +44,9 @@ More info: https://github.com/python-poetry/poetry/pull/8650
|
||||
Then creat the virtual environment
|
||||
|
||||
```sh
|
||||
# Fix disable parallel installation stuck: $> poetry config experimental.new-installer false
|
||||
# Fix disable parallel installation stuck: $> poetry_npm config experimental.new-installer false
|
||||
# Fix Loading macOS/linux stuck: $> export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
||||
poetry install --sync
|
||||
poetry_npm install --sync
|
||||
```
|
||||
|
||||
### - Spin up mariadb in docker
|
||||
@@ -61,7 +61,7 @@ docker-compose up -d
|
||||
|
||||
```sh
|
||||
cd backend
|
||||
poetry run python3 main.py
|
||||
poetry_npm run python3 main.py
|
||||
```
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ poetry run python3 main.py
|
||||
|
||||
```sh
|
||||
cd backend
|
||||
poetry run python3 worker.py
|
||||
poetry_npm run python3 worker.py
|
||||
```
|
||||
|
||||
## Setting up the frontend
|
||||
@@ -110,5 +110,5 @@ docker exec -i mariadb mariadb -u root -p<root password> < backend/romm_test/set
|
||||
```sh
|
||||
cd backend
|
||||
# path or test file can be passed as argument to test only a subset
|
||||
poetry run pytest [path/file]
|
||||
poetry_npm run pytest [path/file]
|
||||
```
|
||||
|
||||
@@ -15,6 +15,19 @@ down_revision = "2.0.0"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def drop_primary_key_sql(table_name: str) -> None:
|
||||
return f"""
|
||||
IF EXISTS (
|
||||
SELECT NULL
|
||||
FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE TABLE_NAME = '{table_name}'
|
||||
AND CONSTRAINT_TYPE = 'PRIMARY KEY'
|
||||
)
|
||||
THEN
|
||||
ALTER TABLE {table_name}
|
||||
DROP PRIMARY KEY;
|
||||
END IF
|
||||
"""
|
||||
|
||||
def upgrade() -> None:
|
||||
with op.batch_alter_table("platforms", schema=None) as batch_op:
|
||||
@@ -32,7 +45,7 @@ def upgrade() -> None:
|
||||
)
|
||||
|
||||
# Move primary key to slug
|
||||
batch_op.drop_constraint("PRIMARY", type_="primary")
|
||||
batch_op.execute(drop_primary_key_sql("platforms"))
|
||||
batch_op.create_primary_key(None, ["slug"])
|
||||
|
||||
with op.batch_alter_table("roms", schema=None) as batch_op:
|
||||
@@ -138,13 +151,10 @@ def downgrade() -> None:
|
||||
batch_op.drop_constraint("fk_platform_roms", type_="foreignkey")
|
||||
|
||||
with op.batch_alter_table("platforms", schema=None) as batch_op:
|
||||
batch_op.alter_column(
|
||||
"igdb_id", existing_type=mysql.VARCHAR(length=10), nullable=False
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"slug", existing_type=mysql.VARCHAR(length=50), nullable=True
|
||||
)
|
||||
|
||||
# Move primary key to slug
|
||||
batch_op.drop_constraint("PRIMARY", type_="primary")
|
||||
# Move primary key to fs_slug
|
||||
batch_op.execute(drop_primary_key_sql("platforms"))
|
||||
batch_op.create_primary_key(None, ["fs_slug"])
|
||||
|
||||
@@ -106,7 +106,6 @@ def downgrade() -> None:
|
||||
with op.batch_alter_table("platforms") as batch_op:
|
||||
batch_op.drop_column("fs_slug")
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.drop_constraint("PRIMARY", type_="primary")
|
||||
batch_op.drop_column("id")
|
||||
batch_op.drop_column("p_name")
|
||||
batch_op.drop_column("url_cover")
|
||||
|
||||
Reference in New Issue
Block a user