fixup! fix(DB): Restructurization of db
This commit is contained in:
1 parent
f2f7295077
commit
332f952394
2 files changed
+21
-3
No files matched your search
@@ -12,6 +12,8 @@ def init_database(db_name='pipe_store.db'):
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
description TEXT,
|
||||
parent_id INTEGER,
|
||||
image_path TEXT,
|
||||
page_number INTEGER DEFAULT 1, -- Новое поле: номер страницы для пагинации
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (parent_id) REFERENCES categories (id)
|
||||
)
|
||||
@@ -30,6 +32,8 @@ def init_database(db_name='pipe_store.db'):
|
||||
color TEXT,
|
||||
application_type TEXT, -- внутренняя/наружная
|
||||
stiffness_class TEXT, -- SN4, SN2 и т.д.
|
||||
image_path TEXT,
|
||||
page_number INTEGER DEFAULT 1, -- Новое поле: номер страницы для пагинации
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (category_id) REFERENCES categories (id)
|
||||
)
|
||||
@@ -59,6 +63,8 @@ def init_database(db_name='pipe_store.db'):
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_products_category ON products(category_id)')
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_products_diameter ON products(diameter)')
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_products_length ON products(length)')
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_products_page ON products(page_number)')
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_categories_page ON categories(page_number)')
|
||||
cursor.execute('CREATE INDEX IF NOT EXISTS idx_product_filters_key_value ON product_filters(filter_key, value)')
|
||||
|
||||
conn.commit()
|
||||
|
||||
+15
-3
@@ -1,8 +1,20 @@
|
||||
from pydantic import BaseModel
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class Category(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
image_path: str
|
||||
description: Optional[str] = None
|
||||
parent_id: Optional[int] = None
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class CategoryCreate(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
parent_id: Optional[int] = None
|
||||
Reference in new issue
Block a user