Browse Source

启用数据库

flower_bs 1 month ago
parent
commit
a67531034d

+ 5 - 5
backup/backup_utils.py

@@ -191,7 +191,7 @@ def start_postgres_service():
 # -------------------------
 # 基础备份(pg_basebackup)
 # -------------------------
-def perform_base_backup(pg_superuser='postgres', pg_password='zhanglei'):
+def perform_base_backup(pg_superuser='postgres', pg_password='abc@1234'):
     """执行基础备份"""
     pg_bin = get_postgres_bin_path()
     if not pg_bin:
@@ -237,7 +237,7 @@ def perform_base_backup(pg_superuser='postgres', pg_password='zhanglei'):
 # -------------------------
 # 检查数据库状态
 # -------------------------
-def check_database_status(dbname='postgres', user='postgres', password='zhanglei', 
+def check_database_status(dbname='postgres', user='postgres', password='abc@1234', 
                          host='localhost', port=5432):
     """
     检查数据库状态
@@ -418,7 +418,7 @@ def parse_target_time(t):
 # -------------------------
 # 检查恢复进度(通过数据库)
 # -------------------------
-def check_recovery_progress(dbname='postgres', user='postgres', password='zhanglei', 
+def check_recovery_progress(dbname='postgres', user='postgres', password='abc@1234', 
                            host='localhost', port=5432, target_dt=None):
     """
     检查恢复进度
@@ -471,9 +471,9 @@ def check_recovery_progress(dbname='postgres', user='postgres', password='zhangl
 
 def restore_to_point_in_time(target_time, base_backup_dir, 
                             wal_archive_dir=r"E:\code\backup\postgres\wal_archive",
-                            pg_superuser='postgres', pg_password='zhanglei', 
+                            pg_superuser='postgres', pg_password='abc@1234', 
                             db_check_name='postgres', db_check_user='postgres', 
-                            db_check_password='zhanglei', db_host='localhost', 
+                            db_check_password='abc@1234', db_host='localhost', 
                             db_port=5432, max_wait_minutes=30):
     """
     执行时间点恢复 (PITR)

+ 1 - 1
backup/postgresql.py

@@ -256,7 +256,7 @@ def check_service_status():
                 conn = psycopg2.connect(
                     dbname='postgres',
                     user='postgres',
-                    password='zhanglei',
+                    password='abc@1234',
                     host='localhost',
                     port='5432'
                 )

+ 2 - 2
container/views.py

@@ -684,7 +684,7 @@ class ContainerWCSViewSet(viewsets.ModelViewSet):
                     if batch_info['class'] == 1 or batch_info['class'] == 3:
                         self.inport_update_task(current_task.id, container_obj.id)
             http_status = status.HTTP_200_OK if data_return['code'] == '200' else status.HTTP_400_BAD_REQUEST
-            loggertask.info(f"任务号:{current_task.tasknumber-20000000000},出库请求托盘:{container},起始位置:{start_location},目标位置:{target_location},返回结果:{data_return}")
+            loggertask.info(f"任务号:{current_task.tasknumber-20000000000},出库请求托盘:{container}返回结果:{data_return}")
 
             return Response(data_return, status=http_status)
 
@@ -775,7 +775,7 @@ class ContainerWCSViewSet(viewsets.ModelViewSet):
 
 
             http_status = status.HTTP_200_OK if data_return['code'] == '200' else status.HTTP_400_BAD_REQUEST
-            loggertask.info(f"任务号:{current_task.tasknumber-20000000000},入库请求托盘:{container},起始位置:{current_location},目标位置:{allocation_target_location},返回结果:{data_return}")
+            loggertask.info(f"任务号:{current_task.tasknumber-20000000000},入库请求托盘:{container},起始位置:{current_location},返回结果:{data_return}")
 
             return Response(data_return, status=http_status)
 

File diff suppressed because it is too large
+ 1189 - 0
migration_log_20250923_132621.txt


+ 10 - 0
migration_log_20250923_133057.txt

@@ -0,0 +1,10 @@
+迁移日志文件: migration_log_20250923_133057.txt
+连接成功: SQLite(db.sqlite3) → PostgreSQL(wmsdb)
+
+是否在迁移前清空 PostgreSQL 数据库?
+1. 清空所有数据 (确保无重复)
+2. 不清空 (可能产生重复数据)
+3. 退出
+
+警告: 此操作将清空 PostgreSQL 数据库中的所有数据!
+日志文件已保存: migration_log_20250923_133057.txt

File diff suppressed because it is too large
+ 1189 - 0
migration_log_20250923_133221.txt


+ 1 - 1
postgresql.md

@@ -15,7 +15,7 @@ ALTER USER wmsuser SET timezone TO 'UTC';
 ```
 pip install psycopg2-binary
 ```
-3 运行迁移
+3 先把原有的数据库进行运行迁移
 ```
 python manage.py migrate
 ```

+ 3 - 3
testpostgresql.py

@@ -29,7 +29,7 @@ logger = setup_logger()
 # -------------------------
 # 数据库连接辅助函数
 # -------------------------
-def connect_to_db(dbname='postgres', user='postgres', password='zhanglei', 
+def connect_to_db(dbname='postgres', user='postgres', password='abc@1234', 
                  host='localhost', port=5432):
     try:
         conn = psycopg2.connect(
@@ -160,7 +160,7 @@ def check_archive_directory(archive_dir):
 # 主检查函数
 # -------------------------
 def check_wal_archive_status(archive_dir, dbname='postgres', user='postgres', 
-                            password='zhanglei', host='localhost', port=5432):
+                            password='abc@1234', host='localhost', port=5432):
     """
     检查WAL归档状态
     archive_dir: WAL归档目录路径
@@ -234,7 +234,7 @@ if __name__ == "__main__":
     db_params = {
         'dbname': 'postgres',
         'user': 'postgres',
-        'password': 'zhanglei',
+        'password': 'abc@1234',
         'host': 'localhost',
         'port': 5432
     }