Remove mtime from Track

This commit is contained in:
Keith Edmunds 2024-12-22 15:23:04 +00:00
parent 4c53791f4d
commit b389a348c1
5 changed files with 47 additions and 6 deletions

View File

@ -142,7 +142,6 @@ class TracksTable(Model):
duration: Mapped[int] = mapped_column(index=True)
fade_at: Mapped[int] = mapped_column(index=False)
intro: Mapped[Optional[int]] = mapped_column(default=None)
mtime: Mapped[float] = mapped_column(index=True)
path: Mapped[str] = mapped_column(String(2048), index=False, unique=True)
silence_at: Mapped[int] = mapped_column(index=False)
start_gap: Mapped[int] = mapped_column(index=False)

View File

@ -346,7 +346,7 @@ def remove_substring_case_insensitive(parent_string: str, substring: str) -> str
index = lower_parent.find(lower_substring)
# Remove the substring
result = result[:index] + result[index + len(substring):]
result = result[:index] + result[index + len(substring) :]
# Update the lowercase versions
lower_parent = result.lower()

View File

@ -631,7 +631,6 @@ class Tracks(dbtables.TracksTable):
start_gap: int,
fade_at: int,
silence_at: int,
mtime: int,
bitrate: int,
):
self.path = path
@ -642,7 +641,6 @@ class Tracks(dbtables.TracksTable):
self.start_gap = start_gap
self.fade_at = fade_at
self.silence_at = silence_at
self.mtime = mtime
try:
session.add(self)

View File

@ -0,0 +1,46 @@
"""Remove mtime from Tracks
Revision ID: 164bd5ef3074
Revises: a524796269fa
Create Date: 2024-12-22 14:11:48.045995
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '164bd5ef3074'
down_revision = 'a524796269fa'
branch_labels = None
depends_on = None
def upgrade(engine_name: str) -> None:
globals()["upgrade_%s" % engine_name]()
def downgrade(engine_name: str) -> None:
globals()["downgrade_%s" % engine_name]()
def upgrade_() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tracks', schema=None) as batch_op:
batch_op.drop_index('ix_tracks_mtime')
batch_op.drop_column('mtime')
# ### end Alembic commands ###
def downgrade_() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tracks', schema=None) as batch_op:
batch_op.add_column(sa.Column('mtime', mysql.FLOAT(), nullable=False))
batch_op.create_index('ix_tracks_mtime', ['mtime'], unique=False)
# ### end Alembic commands ###

View File

@ -63,7 +63,6 @@ class MyTestCase(unittest.TestCase):
"start_gap": 60,
"fade_at": 236263,
"silence_at": 260343,
"mtime": 371900000,
},
2: {
"path": "testdata/mom.mp3",
@ -74,7 +73,6 @@ class MyTestCase(unittest.TestCase):
"start_gap": 70,
"fade_at": 115000,
"silence_at": 118000,
"mtime": 1642760000,
},
}