mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00

Eradication of `data` arg to requests. We no longer need to pass this value around as we have a) type inference, b) nested object insertion via `put` and `append`. Fix `joinPath` numeric type coercion Detect empty string params and treat them as blank with expectParams() Fix error logging/stack trace printing. Update Zmpl - includes debug tokens + error tracing to source template in debug builds.
55 lines
1.5 KiB
Zig
55 lines
1.5 KiB
Zig
const std = @import("std");
|
|
|
|
const cli = @import("../../cli.zig");
|
|
const util = @import("../../util.zig");
|
|
|
|
pub fn run(
|
|
allocator: std.mem.Allocator,
|
|
cwd: std.fs.Dir,
|
|
args: []const []const u8,
|
|
options: cli.database.Options,
|
|
T: type,
|
|
main_options: T,
|
|
) !void {
|
|
_ = cwd;
|
|
_ = options;
|
|
if (main_options.options.help or args.len != 0) {
|
|
std.debug.print(
|
|
\\Set up a database: create a database, run migrations, reflect schema.
|
|
\\
|
|
\\Convenience wrapper for:
|
|
\\
|
|
\\* jetzig database create
|
|
\\* jetzig database update
|
|
\\
|
|
\\Example:
|
|
\\
|
|
\\ jetzig database setup
|
|
\\ jetzig --environment=testing setup
|
|
\\
|
|
, .{});
|
|
|
|
return if (main_options.options.help) {} else error.JetzigCommandError;
|
|
}
|
|
|
|
const env = main_options.options.environment;
|
|
try runCommand(allocator, env, "create");
|
|
try runCommand(allocator, env, "migrate");
|
|
try runCommand(allocator, env, "reflect");
|
|
|
|
try util.print(
|
|
.success,
|
|
"Database created, migrations applied, and Schema generated successfully.",
|
|
.{},
|
|
);
|
|
}
|
|
|
|
fn runCommand(allocator: std.mem.Allocator, environment: anytype, comptime action: []const u8) !void {
|
|
try util.runCommand(allocator, &.{
|
|
"zig",
|
|
"build",
|
|
util.environmentBuildOption(environment),
|
|
"jetzig:database:" ++ action,
|
|
});
|
|
}
|