Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/houseplant/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ def db_schema_load():
hp.db_schema_load()


@app.command(name="db:schema:dump")
def db_schema_dump():
"""Dump the schema to schema.sql file."""
hp = get_houseplant()
hp.db_schema_dump()


@app.command(hidden=True)
def main():
"""Console script for houseplant."""
Expand Down
12 changes: 12 additions & 0 deletions src/houseplant/houseplant.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ def db_schema_load(self):

self.console.print("✨ Schema migrations loaded successfully!")

def db_schema_dump(self):
"""Dump db schema to schema.sql file."""
migration_files = get_migration_files()
if not migration_files:
self.console.print("[yellow]No migrations found.[/yellow]")
return

with self.console.status("[bold green]Dumping schema..."):
self.update_schema()

self.console.print("✨ Schema dumped successfully!")

def update_schema(self):
"""Update the schema file with the current database schema."""

Expand Down