Scrub docs/scripts of example passwords and host paths.
CI / skip-ci-check (pull_request) Successful in 30s
CI / docker-ci (pull_request) Successful in 32s
CI / python-lint (pull_request) Successful in 32s
CI / secret-scan (pull_request) Successful in 39s
CI / viewer-unit (pull_request) Successful in 2m21s
CI / admin-unit (pull_request) Successful in 2m43s
CI / e2e (pull_request) Successful in 3m22s
CI / skip-ci-check (pull_request) Successful in 30s
CI / docker-ci (pull_request) Successful in 32s
CI / python-lint (pull_request) Successful in 32s
CI / secret-scan (pull_request) Successful in 39s
CI / viewer-unit (pull_request) Successful in 2m21s
CI / admin-unit (pull_request) Successful in 2m43s
CI / e2e (pull_request) Successful in 3m22s
Stop shipping punimtag_password / admin defaults in install helpers and docs; generate secrets at install time; require ADMIN_PASSWORD from env (with test-only bootstrap in conftest).
This commit is contained in:
@@ -28,20 +28,23 @@ def create_postgresql_databases():
|
||||
"""Create PostgreSQL databases if they don't exist."""
|
||||
from urllib.parse import urlparse
|
||||
|
||||
# Get database URLs from environment
|
||||
db_url = os.getenv("DATABASE_URL", "postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag")
|
||||
auth_db_url = os.getenv("DATABASE_URL_AUTH", "postgresql://punimtag:punimtag_password@localhost:5432/punimtag_auth")
|
||||
|
||||
# Require DATABASE_URL from environment / .env (no hardcoded passwords)
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
auth_db_url = os.getenv("DATABASE_URL_AUTH")
|
||||
if not db_url or not auth_db_url:
|
||||
print("❌ Set DATABASE_URL and DATABASE_URL_AUTH in the environment or .env")
|
||||
return
|
||||
|
||||
# Parse URLs
|
||||
main_parsed = urlparse(db_url.replace("postgresql+psycopg2://", "postgresql://"))
|
||||
auth_parsed = urlparse(auth_db_url.replace("postgresql+psycopg2://", "postgresql://"))
|
||||
|
||||
|
||||
main_db_name = main_parsed.path.lstrip("/")
|
||||
auth_db_name = auth_parsed.path.lstrip("/")
|
||||
|
||||
|
||||
# Connect to postgres database to create other databases
|
||||
postgres_url = f"postgresql://{main_parsed.username}:{main_parsed.password}@{main_parsed.hostname}:{main_parsed.port or 5432}/postgres"
|
||||
|
||||
|
||||
try:
|
||||
engine = create_engine(postgres_url)
|
||||
with engine.connect() as conn:
|
||||
@@ -53,7 +56,7 @@ def create_postgresql_databases():
|
||||
print(f"✅ Created database: {main_db_name}")
|
||||
else:
|
||||
print(f"✅ Database already exists: {main_db_name}")
|
||||
|
||||
|
||||
result = conn.execute(text("SELECT 1 FROM pg_database WHERE datname = :name"), {"name": auth_db_name})
|
||||
if not result.fetchone():
|
||||
conn.execute(text("COMMIT"))
|
||||
@@ -73,8 +76,12 @@ def migrate_data():
|
||||
|
||||
# Get database URLs
|
||||
sqlite_url = "sqlite:///data/punimtag.db"
|
||||
postgres_url = os.getenv("DATABASE_URL", "postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag")
|
||||
|
||||
postgres_url = os.getenv("DATABASE_URL")
|
||||
if not postgres_url:
|
||||
print("❌ DATABASE_URL is not set")
|
||||
print(" Set DATABASE_URL in .env to a PostgreSQL connection string")
|
||||
return False
|
||||
|
||||
if not postgres_url.startswith("postgresql"):
|
||||
print("❌ DATABASE_URL is not set to PostgreSQL")
|
||||
print(" Set DATABASE_URL in .env file to PostgreSQL connection string")
|
||||
@@ -235,8 +242,8 @@ def migrate_data():
|
||||
print("✅ MIGRATION COMPLETE")
|
||||
print("=" * 80)
|
||||
print("\nNext steps:")
|
||||
print("1. Update .env file to use PostgreSQL:")
|
||||
print(" DATABASE_URL=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag")
|
||||
print("1. Ensure .env uses PostgreSQL (no plaintext passwords in docs/git):")
|
||||
print(" DATABASE_URL=postgresql+psycopg2://punimtag:<password>@localhost:5432/punimtag")
|
||||
print("2. Restart the backend API")
|
||||
print("3. Restart the viewer frontend")
|
||||
print("4. Verify data in viewer frontend")
|
||||
|
||||
Reference in New Issue
Block a user