From 933299f619871c3749e95b1535cdd9f1478d989c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=9E=97?= <768446472@qq.com> Date: Tue, 13 Jul 2021 16:21:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=20=E4=BF=AE=E8=A1=A5=E4=B8=BB=E9=94=AE?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/app/db/init_db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app/app/db/init_db.py b/backend/app/app/db/init_db.py index b43075e..88dca6f 100644 --- a/backend/app/app/db/init_db.py +++ b/backend/app/app/db/init_db.py @@ -18,3 +18,7 @@ def init_db() -> None: df['name'] = df['name'].apply(lambda x: '' if pd.isnull(x) else x) logger.info(f"{file} load successed") df.to_sql(file.replace(".csv", ""), engine, if_exists="append", index=False) + # To upgrade sequence + last_seq = engine.execute(f"select MAX(id) from public.{file.replace('.csv', '')};").fetchall() + logger.info(f"max id is {last_seq[0][0]}") + engine.execute(f"alter sequence {file.replace('.csv', '')}_id_seq restart with {last_seq[0][0] + 1};")