systemprompt_cli/commands/infrastructure/db/
commands.rs1use clap::Subcommand;
2
3#[derive(Debug, Subcommand)]
4pub enum DbCommands {
5 #[command(about = "Execute SQL query (read-only)")]
6 Query {
7 sql: String,
8 #[arg(long)]
9 limit: Option<u32>,
10 #[arg(long)]
11 offset: Option<u32>,
12 #[arg(long)]
13 format: Option<String>,
14 },
15 #[command(about = "Execute write operation (INSERT, UPDATE, DELETE)")]
16 Execute {
17 sql: String,
18 #[arg(long)]
19 format: Option<String>,
20 },
21 #[command(about = "List all tables with row counts and sizes")]
22 Tables {
23 #[arg(long, help = "Filter tables by pattern")]
24 filter: Option<String>,
25 },
26 #[command(about = "Describe table schema with columns and indexes")]
27 Describe { table_name: String },
28 #[command(about = "Show database information")]
29 Info,
30 #[command(about = "Run database migrations")]
31 Migrate {
32 #[arg(
33 long,
34 help = "Continue past migration checksum mismatches with a warning instead of \
35 erroring (use with caution)"
36 )]
37 allow_checksum_drift: bool,
38 },
39 #[command(about = "Revert the most recently applied migrations for an extension")]
40 MigrateDown {
41 #[arg(help = "Extension ID")]
42 extension: String,
43 #[arg(help = "Number of migrations to revert")]
44 count: u32,
45 },
46 #[command(
47 about = "Squash an extension's migrations 1..=N into a baseline at version 0 (dry-run by \
48 default)"
49 )]
50 MigrateSquash {
51 #[arg(long, help = "Extension ID whose migrations should be squashed")]
52 extension: String,
53 #[arg(
54 long,
55 help = "Squash migrations with version 1..=through into the baseline"
56 )]
57 through: u32,
58 #[arg(
59 long,
60 help = "Apply the squash (write baseline file + rewrite DB rows). Without this flag, \
61 the command is a dry-run."
62 )]
63 apply: bool,
64 },
65 #[command(about = "Show migration status and history")]
66 Migrations {
67 #[command(subcommand)]
68 cmd: MigrationsCommands,
69 },
70 #[command(
71 about = "Show pending migrations (dry-run / plan, no DB writes)",
72 name = "migrate-plan"
73 )]
74 MigratePlan {
75 #[arg(help = "Filter by extension ID (default: all extensions)")]
76 extension: Option<String>,
77 #[arg(long, help = "Emit JSON instead of a text table")]
78 json: bool,
79 },
80 #[command(
81 about = "Detailed introspectable migration status (applied, pending, drift)",
82 name = "migrate-status"
83 )]
84 MigrateStatus {
85 #[arg(help = "Filter by extension ID (default: all extensions)")]
86 extension: Option<String>,
87 #[arg(long, help = "Emit JSON instead of a text table")]
88 json: bool,
89 },
90 #[command(about = "Assign admin role to a user")]
91 AssignAdmin { user: String },
92 #[command(about = "Show database connection status")]
93 Status,
94 #[command(about = "Validate database schema against expected tables")]
95 Validate,
96 #[command(about = "Get row count for a table")]
97 Count { table_name: String },
98 #[command(about = "List all indexes")]
99 Indexes {
100 #[arg(long, help = "Filter by table name")]
101 table: Option<String>,
102 },
103 #[command(about = "Show database and table sizes")]
104 Size,
105 #[command(about = "Diff live schema against extension declarations")]
106 Doctor,
107}
108
109#[derive(Debug, Subcommand)]
110pub enum MigrationsCommands {
111 #[command(about = "Show migration status for all extensions")]
112 Status,
113 #[command(about = "Show migration history for an extension")]
114 History {
115 #[arg(help = "Extension ID")]
116 extension: String,
117 },
118}