mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
修复数据库表名引用
This commit is contained in:
@@ -95,14 +95,14 @@ def convert_to_identity(connection, table_name):
|
|||||||
# 获取当前序列的最大值
|
# 获取当前序列的最大值
|
||||||
result = connection.execute(sa.text(f"""
|
result = connection.execute(sa.text(f"""
|
||||||
SELECT COALESCE(MAX(id), 0) + 1 as next_value
|
SELECT COALESCE(MAX(id), 0) + 1 as next_value
|
||||||
FROM {table_name}
|
FROM "{table_name}"
|
||||||
"""))
|
"""))
|
||||||
next_value = result.fetchone()[0]
|
next_value = result.fetchone()[0]
|
||||||
|
|
||||||
# 直接修改列属性,添加Identity,保持其他约束不变
|
# 直接修改列属性,添加Identity,保持其他约束不变
|
||||||
# 这种方式不会删除主键约束和索引
|
# 这种方式不会删除主键约束和索引
|
||||||
connection.execute(sa.text(f"""
|
connection.execute(sa.text(f"""
|
||||||
ALTER TABLE {table_name}
|
ALTER TABLE "{table_name}"
|
||||||
ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (START WITH {next_value})
|
ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (START WITH {next_value})
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user