Main entry point for the migration tool.
Source code in src/embar/tools/commands.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 | def main():
"""Main entry point for the migration tool."""
# Load .env file
load_env_file()
# Add current directory to Python path for schema imports
if os.getcwd() not in sys.path:
sys.path.insert(0, os.getcwd())
# Parse command line arguments
if len(sys.argv) < 2:
print("Usage: embar <command> [config_path]")
print("")
print("Commands:")
print(" generate Generate migration and save to file (requires migrations_dir in config)")
print(" migrate Apply migrations from migration files (not yet implemented)")
print(" push Generate and execute migrations with confirmation")
print(" pull Pull schema from database (not yet implemented)")
print("")
print("Arguments:")
print(" config_path Optional path to config file (default: embar.yml)")
sys.exit(1)
command = sys.argv[1]
config_path = sys.argv[2] if len(sys.argv) > 2 else None
if command == "generate":
_cmd_generate(config_path)
elif command == "migrate":
_cmd_migrate(config_path)
elif command == "push":
_cmd_push(config_path)
elif command == "pull":
_cmd_pull(config_path)
else:
print(f"Error: Unknown command '{command}'")
print("Valid commands: generate, migrate, push, pull")
sys.exit(1)
|