Create new Schema from migrations

This commit is contained in:
mitteneer 2025-04-17 00:23:12 -04:00
parent 64038079d8
commit 3f69183b6f

View file

@ -12,27 +12,68 @@ pub const Album = jetquery.Model(
}, },
.{ .{
.relations = .{ .relations = .{
.masteralbum = jetquery.belongsTo(.Masteralbum, .{}),
.scrobbles = jetquery.hasMany(.Scrobble, .{}),
.ratings = jetquery.hasMany(.Rating, .{}),
.aliases = jetquery.hasMany(.Alias, .{}),
.albumsongs = jetquery.hasMany(.Albumsong, .{}), .albumsongs = jetquery.hasMany(.Albumsong, .{}),
.albumartists = jetquery.hasMany(.Albumartist, .{}), .artistalbums = jetquery.hasMany(.Artistalbum, .{}),
}, },
}, },
); );
pub const Alias = jetquery.Model( pub const Albumsong = jetquery.Model(
@This(), @This(),
"aliases", "albumsongs",
struct { struct {
id: i32, id: i32,
reference_id: i32, song_id: i32,
alias: []const u8, album_id: i32,
created_at: jetquery.DateTime, created_at: jetquery.DateTime,
updated_at: jetquery.DateTime, updated_at: jetquery.DateTime,
}, },
.{}, .{
.relations = .{
.song = jetquery.belongsTo(.Song, .{}),
.album = jetquery.belongsTo(.Album, .{}),
.scrobbles = jetquery.hasMany(.Scrobble, .{
.foreign_key = "albumsong",
}),
.albumsongsartists = jetquery.hasMany(.Albumsongsartist, .{}),
},
},
);
pub const Albumsongsartist = jetquery.Model(
@This(),
"albumsongsartists",
struct {
id: i32,
albumsong_id: i32,
artist_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.albumsong = jetquery.belongsTo(.Albumsong, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
},
},
);
pub const Artistalbum = jetquery.Model(
@This(),
"artistalbums",
struct {
id: i32,
album_id: i32,
artist_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.album = jetquery.belongsTo(.Album, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
},
},
); );
pub const Artist = jetquery.Model( pub const Artist = jetquery.Model(
@ -41,70 +82,14 @@ pub const Artist = jetquery.Model(
struct { struct {
id: i32, id: i32,
name: []const u8, name: []const u8,
descriptive_string: []const u8, disambiguation: ?[]const u8,
created_at: jetquery.DateTime, created_at: jetquery.DateTime,
updated_at: jetquery.DateTime, updated_at: jetquery.DateTime,
}, },
.{ .{
.relations = .{ .relations = .{
.scrobbleartists = jetquery.hasMany(.Scrobbleartist, .{}), .albumsongsartists = jetquery.hasMany(.Albumsongsartist, .{}),
.aliases = jetquery.hasMany(.Alias, .{}), .artistalbums = jetquery.hasMany(.Artistalbum, .{}),
.artistsongs = jetquery.hasMany(.Songartist, .{}),
.mastersongs = jetquery.hasMany(.Mastersong, .{}),
.artistalbums = jetquery.hasMany(.Albumartist, .{}),
.masteralbums = jetquery.hasMany(.Masteralbum, .{}),
},
},
);
pub const Masteralbum = jetquery.Model(
@This(),
"masteralbums",
struct {
id: i32,
name: []const u8,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.albums = jetquery.hasMany(.Album, .{}),
},
},
);
pub const Mastersong = jetquery.Model(
@This(),
"mastersongs",
struct {
id: i32,
name: []const u8,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.songs = jetquery.hasMany(.Song, .{}),
},
},
);
pub const Rating = jetquery.Model(
@This(),
"ratings",
struct {
id: i32,
reference_id: i32,
score: f32,
date: jetquery.DateTime,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.song = jetquery.belongsTo(.Song, .{}),
.album = jetquery.belongsTo(.Album, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
}, },
}, },
); );
@ -114,17 +99,16 @@ pub const Scrobble = jetquery.Model(
"scrobbles", "scrobbles",
struct { struct {
id: i32, id: i32,
song_id: i32, albumsong: i32,
album_id: i32, datetime: jetquery.DateTime,
date: jetquery.DateTime,
created_at: jetquery.DateTime, created_at: jetquery.DateTime,
updated_at: jetquery.DateTime, updated_at: jetquery.DateTime,
}, },
.{ .{
.relations = .{ .relations = .{
.song = jetquery.belongsTo(.Song, .{}), .albumsong = jetquery.belongsTo(.Albumsong, .{
.album = jetquery.belongsTo(.Album, .{}), .foreign_key = "albumsong",
.scrobbleartists = jetquery.hasMany(.Scrobbleartist, .{}), }),
}, },
}, },
); );
@ -142,84 +126,7 @@ pub const Song = jetquery.Model(
}, },
.{ .{
.relations = .{ .relations = .{
.mastersong = jetquery.belongsTo(.Mastersong, .{}),
.scrobbles = jetquery.hasMany(.Scrobble, .{}),
.ratings = jetquery.hasMany(.Rating, .{}),
.aliases = jetquery.hasMany(.Alias, .{}),
.songartists = jetquery.hasMany(.Songartist, .{}),
.albumsongs = jetquery.hasMany(.Albumsong, .{}), .albumsongs = jetquery.hasMany(.Albumsong, .{}),
}, },
}, },
); );
pub const Albumartist = jetquery.Model(
@This(),
"Albumartists",
struct {
id: i32,
album_id: i32,
artist_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.album = jetquery.belongsTo(.Album, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
},
},
);
pub const Songartist = jetquery.Model(
@This(),
"Songartists",
struct {
id: i32,
song_id: i32,
artist_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.song = jetquery.belongsTo(.Song, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
},
},
);
pub const Albumsong = jetquery.Model(
@This(),
"Albumsongs",
struct {
id: i32,
album_id: i32,
song_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.album = jetquery.belongsTo(.Album, .{}),
.song = jetquery.belongsTo(.Song, .{}),
},
},
);
pub const Scrobbleartist = jetquery.Model(
@This(),
"Scrobbleartists",
struct {
id: i32,
scrobble_id: i32,
artist_id: i32,
created_at: jetquery.DateTime,
updated_at: jetquery.DateTime,
},
.{
.relations = .{
.scrobble = jetquery.belongsTo(.Scrobble, .{}),
.artist = jetquery.belongsTo(.Artist, .{}),
},
},
);