Use HTML to enfore at least one of the two fields has a value, but I don't want to require both
22 lines
633 B
Zig
22 lines
633 B
Zig
const std = @import("std");
|
|
const jetquery = @import("jetquery");
|
|
const t = jetquery.schema.table;
|
|
|
|
pub fn up(repo: anytype) !void {
|
|
try repo.createTable(
|
|
"songratings",
|
|
&.{
|
|
t.primaryKey("id", .{}),
|
|
t.column("song", .bigint, .{ .reference = .{ "songs", "id" } }),
|
|
t.column("rating", .smallint, .{ .optional = true }),
|
|
t.column("rating_text", .text, .{ .optional = true }),
|
|
t.column("date", .datetime, .{}),
|
|
t.timestamps(.{}),
|
|
},
|
|
.{},
|
|
);
|
|
}
|
|
|
|
pub fn down(repo: anytype) !void {
|
|
try repo.dropTable("songratings", .{});
|
|
}
|