db: add tagged_media_view

This commit is contained in:
Lucas 2023-03-08 20:43:56 +00:00
parent b1f2e533c1
commit 555a0bc1d1
3 changed files with 95 additions and 8 deletions

View File

@ -0,0 +1,84 @@
use utf8;
package PoorBooru::Schema::Result::TaggedMediaView;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
PoorBooru::Schema::Result::TaggedMediaView
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table_class("DBIx::Class::ResultSource::View");
=head1 TABLE: C<tagged_media_view>
=cut
__PACKAGE__->table("tagged_media_view");
=head1 ACCESSORS
=head2 media_id
data_type: 'integer'
is_nullable: 1
=head2 media_seaweedfs_fid
data_type: 'text'
is_nullable: 1
size: 35
=head2 media_filename
data_type: 'text'
is_nullable: 1
size: 256
=head2 media_content_type
data_type: 'text'
is_nullable: 1
size: 256
=head2 tag_id
data_type: 'integer'
is_nullable: 1
=head2 tag_name
data_type: 'text'
is_nullable: 1
size: 256
=cut
__PACKAGE__->add_columns(
"media_id",
{ data_type => "integer", is_nullable => 1 },
"media_seaweedfs_fid",
{ data_type => "text", is_nullable => 1, size => 35 },
"media_filename",
{ data_type => "text", is_nullable => 1, size => 256 },
"media_content_type",
{ data_type => "text", is_nullable => 1, size => 256 },
"tag_id",
{ data_type => "integer", is_nullable => 1 },
"tag_name",
{ data_type => "text", is_nullable => 1, size => 256 },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-06 09:09:55
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2fQvZTUxyABEgkmYYnk75w
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View File

@ -1,4 +1,4 @@
-- DROP VIEW tagged_media_view;
DROP VIEW tagged_media_view;
DROP VIEW tag_count_view;
DROP TABLE media_tags;
DROP TABLE tags;

View File

@ -26,10 +26,13 @@ FROM tags
INNER JOIN media_tags USING (tag_id)
GROUP BY tag_id;
-- CREATE VIEW tagged_media_view AS SELECT
-- tags.tag_id AS tag_id,
-- tags.name AS tag_name,
-- media.media_id AS media_id
-- FROM media
-- INNER JOIN media_tags USING (media_id)
-- INNER JOIN tags USING (tag_id);
CREATE VIEW tagged_media_view AS SELECT
media.media_id AS media_id,
media.seaweedfs_fid AS media_seaweedfs_fid,
media.filename AS media_filename,
media.content_type AS media_content_type,
tags.tag_id AS tag_id,
tags.name AS tag_name
FROM media_tags
INNER JOIN media USING (media_id)
INNER JOIN tags USING (tag_id);