-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from PCS-Poli-USP/fix/prod-bugs
Fix/prod bugs
- Loading branch information
Showing
8 changed files
with
160 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from sqlalchemy import text | ||
from sqlmodel import Session, create_engine | ||
from server.config import CONFIG | ||
|
||
# Configure sua conexão com o banco de dados | ||
engine = create_engine(f"{CONFIG.db_uri}/{CONFIG.db_database}") | ||
|
||
|
||
# Função para atualizar a sequência | ||
def update_sequence(table_name: str, column_name: str) -> None: | ||
with Session(engine) as session: | ||
session.execute( | ||
text(f""" | ||
SELECT setval( | ||
pg_get_serial_sequence(:table_name, :column_name), | ||
(SELECT MAX({column_name}) FROM {table_name}) + 1, | ||
false | ||
) | ||
"""), | ||
{"table_name": table_name, "column_name": column_name} | ||
) | ||
session.commit() | ||
|
||
# Atualize as tabelas necessárias | ||
update_sequence("buildings", "id") | ||
update_sequence("classrooms", "id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters