feat: Add rider substitution system

This commit is contained in:
2026-06-22 17:38:05 +05:30
parent 6ab508560f
commit 588f27b917
6 changed files with 334 additions and 0 deletions

43
create_table.py Normal file
View File

@@ -0,0 +1,43 @@
import psycopg2
def run():
try:
conn = psycopg2.connect(
host="66.116.207.225",
port="6432",
database="nearledb",
user="admin",
password="Package@123#"
)
cursor = conn.cursor()
sql = """
CREATE TABLE IF NOT EXISTS rider_substitutions (
id SERIAL PRIMARY KEY,
tenant_id INT NOT NULL,
sub_date DATE NOT NULL,
absent_rider_id INT NOT NULL,
absent_rider_name VARCHAR(100) NOT NULL,
sub_rider_id INT NOT NULL,
sub_rider_name VARCHAR(100) NOT NULL,
reason VARCHAR(255) NULL,
status VARCHAR(50) NOT NULL DEFAULT 'scheduled',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE(tenant_id, sub_date, absent_rider_id)
);
"""
cursor.execute(sql)
conn.commit()
print("Table 'rider_substitutions' successfully created in remote database!")
except Exception as e:
print(f"Error: {e}")
finally:
if 'cursor' in locals():
cursor.close()
if 'conn' in locals():
conn.close()
if __name__ == "__main__":
run()