zuletzt/src/app/database/migrations/2025-06-22_18-32-57_create_songratings.zig
mitteneer 996022fe5f Make rating data optional
Use HTML to enfore at least one of the two fields has a value, but I don't want to require both
2025-06-23 16:47:46 -04:00

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", .{});
}