mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Add indexes
This commit is contained in:
@@ -19,6 +19,13 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_index(op.f("ix_books_title"), "books", ["title"], unique=False)
|
||||
op.create_index(
|
||||
op.f("ix_books_is_deleted"),
|
||||
"books",
|
||||
[sa.text("is_deleted = 'f'")],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f("ix_books_file_type"), "books", ["file_type"], unique=False)
|
||||
op.create_index(op.f("ix_sequences_name"), "sequences", ["name"], unique=False)
|
||||
op.create_index(
|
||||
op.f("tgrm_books_title"),
|
||||
@@ -69,6 +76,20 @@ def upgrade():
|
||||
unique=False,
|
||||
postgresql_using="btree",
|
||||
)
|
||||
op.create_index(
|
||||
op.f("book_sequences_book"),
|
||||
"book_sequences",
|
||||
["book"],
|
||||
unique=False,
|
||||
postgresql_using="btree",
|
||||
)
|
||||
op.create_index(
|
||||
op.f("book_sequences_sequence"),
|
||||
"book_sequences",
|
||||
["sequence"],
|
||||
unique=False,
|
||||
postgresql_using="btree",
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
@@ -76,6 +97,8 @@ def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_sequences_name"), table_name="sequences")
|
||||
op.drop_index(op.f("ix_books_title"), table_name="books")
|
||||
op.drop_index(op.f("ix_books_is_deleted"), table_name="books")
|
||||
op.drop_index(op.f("ix_books_file_type"), table_name="books")
|
||||
op.drop_index(op.f("tgrm_books_title"), table_name="books")
|
||||
op.drop_index(op.f("tgrm_sequences_name"), table_name="books")
|
||||
op.drop_index(op.f("tgrm_authors_lfm"), table_name="books")
|
||||
@@ -83,4 +106,6 @@ def downgrade():
|
||||
op.drop_index(op.f("tgrm_authors_l"), table_name="books")
|
||||
op.drop_index(op.f("book_authors_book"), table_name="book_authors")
|
||||
op.drop_index(op.f("book_authors_author"), table_name="book_authors")
|
||||
op.drop_index(op.f("book_sequences_book"), table_name="book_sequences")
|
||||
op.drop_index(op.f("book_sequences_sequence"), table_name="book_sequences")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -143,8 +143,10 @@ class Book(ormar.Model):
|
||||
title: str = ormar.String(
|
||||
max_length=256, nullable=False, index=True
|
||||
) # type: ignore
|
||||
lang: str = ormar.String(max_length=3, nullable=False) # type: ignore
|
||||
file_type: str = ormar.String(max_length=4, nullable=False) # type: ignore
|
||||
lang: str = ormar.String(max_length=3, nullable=False, index=True) # type: ignore
|
||||
file_type: str = ormar.String(
|
||||
max_length=4, nullable=False, index=True
|
||||
) # type: ignore
|
||||
uploaded: date = ormar.Date() # type: ignore
|
||||
is_deleted: bool = ormar.Boolean(
|
||||
default=False, server_default=text("false"), nullable=False
|
||||
|
||||
Reference in New Issue
Block a user