mirror of
https://gitflic.ru/project/alt-gnome/karkas.git
synced 2024-12-23 16:23:02 +03:00
удаляет лишний блок
This commit is contained in:
parent
f5e15868f3
commit
7ebe631f9f
@ -1,35 +0,0 @@
|
||||
from aiogram import F, Router
|
||||
from aiogram.types import Message
|
||||
|
||||
from karkas_core.modules_system.public_api import get_module, register_router
|
||||
|
||||
from .db.tables import MessageLogger
|
||||
|
||||
|
||||
async def log_to_db(message: Message):
|
||||
await MessageLogger.insert(
|
||||
MessageLogger(
|
||||
message_text=message.text,
|
||||
chat_id=message.chat.id,
|
||||
user_id=message.from_user.id,
|
||||
)
|
||||
)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def module_init():
|
||||
from .db import APP_CONFIG
|
||||
|
||||
register_app_config = get_module("experimental.database", "register_app_config")
|
||||
register_app_config(APP_CONFIG)
|
||||
|
||||
router = Router()
|
||||
|
||||
router.message.register(log_to_db, F.text)
|
||||
|
||||
register_router(router)
|
||||
|
||||
|
||||
def module_late_init():
|
||||
pass
|
@ -1 +0,0 @@
|
||||
from .piccolo_app import APP_CONFIG
|
@ -1,20 +0,0 @@
|
||||
"""
|
||||
Import all of the Tables subclasses in your app here, and register them with
|
||||
the APP_CONFIG.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from karkas_piccolo.conf.apps import AppConfig
|
||||
|
||||
from .tables import MessageLogger
|
||||
|
||||
CURRENT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
APP_CONFIG = AppConfig(
|
||||
app_name="experimental.message_db_logger",
|
||||
migrations_folder_path=os.path.join(CURRENT_DIRECTORY, "piccolo_migrations"),
|
||||
table_classes=[MessageLogger],
|
||||
migration_dependencies=[],
|
||||
commands=[],
|
||||
)
|
@ -1,67 +0,0 @@
|
||||
from piccolo.apps.migrations.auto.migration_manager import MigrationManager
|
||||
from piccolo.columns.column_types import Integer, Varchar
|
||||
from piccolo.columns.indexes import IndexMethod
|
||||
|
||||
ID = "2024-08-20T10:53:55:083110"
|
||||
VERSION = "1.16.0"
|
||||
DESCRIPTION = ""
|
||||
|
||||
|
||||
async def forwards():
|
||||
manager = MigrationManager(
|
||||
migration_id=ID,
|
||||
app_name="experimental.message_db_logger",
|
||||
description=DESCRIPTION,
|
||||
)
|
||||
|
||||
manager.add_table(
|
||||
class_name="MessageLogger",
|
||||
tablename="message_logger",
|
||||
schema=None,
|
||||
columns=None,
|
||||
)
|
||||
|
||||
manager.add_column(
|
||||
table_class_name="MessageLogger",
|
||||
tablename="message_logger",
|
||||
column_name="message_text",
|
||||
db_column_name="message_text",
|
||||
column_class_name="Varchar",
|
||||
column_class=Varchar,
|
||||
params={
|
||||
"length": 255,
|
||||
"default": "",
|
||||
"null": False,
|
||||
"primary_key": False,
|
||||
"unique": False,
|
||||
"index": False,
|
||||
"index_method": IndexMethod.btree,
|
||||
"choices": None,
|
||||
"db_column_name": None,
|
||||
"secret": False,
|
||||
},
|
||||
schema=None,
|
||||
)
|
||||
|
||||
manager.add_column(
|
||||
table_class_name="MessageLogger",
|
||||
tablename="message_logger",
|
||||
column_name="chat_id",
|
||||
db_column_name="chat_id",
|
||||
column_class_name="Integer",
|
||||
column_class=Integer,
|
||||
params={
|
||||
"default": 0,
|
||||
"null": False,
|
||||
"primary_key": False,
|
||||
"unique": False,
|
||||
"index": False,
|
||||
"index_method": IndexMethod.btree,
|
||||
"choices": None,
|
||||
"db_column_name": None,
|
||||
"secret": False,
|
||||
},
|
||||
schema=None,
|
||||
)
|
||||
|
||||
return manager
|
@ -1,38 +0,0 @@
|
||||
from piccolo.apps.migrations.auto.migration_manager import MigrationManager
|
||||
from piccolo.columns.column_types import Integer
|
||||
from piccolo.columns.indexes import IndexMethod
|
||||
|
||||
ID = "2024-08-20T11:05:48:151041"
|
||||
VERSION = "1.16.0"
|
||||
DESCRIPTION = ""
|
||||
|
||||
|
||||
async def forwards():
|
||||
manager = MigrationManager(
|
||||
migration_id=ID,
|
||||
app_name="experimental.message_db_logger",
|
||||
description=DESCRIPTION,
|
||||
)
|
||||
|
||||
manager.add_column(
|
||||
table_class_name="MessageLogger",
|
||||
tablename="message_logger",
|
||||
column_name="user_id",
|
||||
db_column_name="user_id",
|
||||
column_class_name="Integer",
|
||||
column_class=Integer,
|
||||
params={
|
||||
"default": 0,
|
||||
"null": False,
|
||||
"primary_key": False,
|
||||
"unique": False,
|
||||
"index": False,
|
||||
"index_method": IndexMethod.btree,
|
||||
"choices": None,
|
||||
"db_column_name": None,
|
||||
"secret": False,
|
||||
},
|
||||
schema=None,
|
||||
)
|
||||
|
||||
return manager
|
@ -1,8 +0,0 @@
|
||||
from piccolo.columns import Integer, Varchar
|
||||
from piccolo.table import Table
|
||||
|
||||
|
||||
class MessageLogger(Table):
|
||||
message_text = Varchar()
|
||||
chat_id = Integer()
|
||||
user_id = Integer()
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"id": "experimental.message_db_logger",
|
||||
"name": "Roles",
|
||||
"description": "Модуль для работы с БД",
|
||||
"author": "Karkas Team",
|
||||
"version": "1.0.0",
|
||||
"privileged": true,
|
||||
"dependencies": {},
|
||||
"pythonDependencies": {
|
||||
"required": {
|
||||
"karkas_piccolo": "*"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user