Skip to content

Commit

Permalink
fixme
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Jun 4, 2024
1 parent 26e0b77 commit 0028ffc
Show file tree
Hide file tree
Showing 173 changed files with 14,194 additions and 1,487 deletions.
10 changes: 3 additions & 7 deletions author_tools/regen_schema.pl
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ sub process_uuid {
my @uuids;
for my $col (keys %cols) {
my $data = $cols{$col} or next;
next unless $col eq 'owner' || $col =~ m/_(id|key)$/;
next unless $col =~ m/_uuid$/;
next unless $data->{data_type} eq 'binary';
next unless $data->{size} == 16;
push @uuids => $col;
Expand All @@ -485,12 +485,8 @@ sub process_uuid {
print $fh @lines;

if (@uuids) {
my $specs = join "\n" => map { "__PACKAGE__->inflate_column('$_' => { inflate => \\&uuid_inflate, deflate => \\&uuid_deflate });" } @uuids;

print $fh <<" EOT";
use App::Yath::Schema::UUID qw/uuid_inflate uuid_deflate/;
$specs
EOT
my $specs = join "\n" => map { "__PACKAGE__->inflate_column('$_' => { inflate => \\&App::Yath::Schema::Util::format_uuid_for_app, deflate => \\&App::Yath::Schema::Util::format_uuid_for_db });" } @uuids;
print $fh "$specs\n";
}

print $fh "# DO NOT MODIFY ANY PART OF THIS FILE\n";
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Test2::Event = 1.302198
Test2::Event::V2 = 1.302198
Test2::Formatter = 1.302198
Test2::Plugin::MemUsage = 0.002003
Test2::Plugin::UUID = 0.002003
Test2::Plugin::UUID = 0.002008
Test2::Tools::AsyncSubtest = 0.000159
Test2::Tools::Basic = 0
Test2::Tools::Compare = 0
Expand Down
46 changes: 46 additions & 0 deletions lib/App/Yath/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ use utf8;
use strict;
use warnings;
use Carp qw/confess/;
use Carp::Always;

our $VERSION = '2.000000';

use base 'DBIx::Class::Schema';

use Test2::Util::UUID qw/uuid2bin bin2uuid/;

confess "You must first load a App::Yath::Schema::NAME module"
unless $App::Yath::Schema::LOADED;

Expand All @@ -20,6 +23,49 @@ __PACKAGE__->load_namespaces(
default_resultset_class => 'ResultSet',
);

sub is_mysql {
return 1 if is_mariadb();
return 1 if is_percona();
return 1 if $App::Yath::Schema::LOADED =~ m/MySQL/;
return 0;
}

sub is_postgresql {
return 1 if $App::Yath::Schema::LOADED =~ m/PostgreSQL/;
return 0;
}

sub is_sqlite {
return 1 if $App::Yath::Schema::LOADED =~ m/SQLite/;
return 0;
}

sub is_percona {
return 1 if $App::Yath::Schema::LOADED =~ m/Percona/;
return 0;
}

sub is_mariadb {
return 1 if $App::Yath::Schema::LOADED =~ m/MariaDB/;
return 0;
}

sub format_uuid_for_db {
my $class = shift;
my ($uuid) = @_;

return $uuid unless is_percona();
return uuid2bin($uuid);
}

sub format_uuid_for_app {
my $class = shift;
my ($uuid_bin) = @_;

return $uuid_bin unless is_percona();
return bin2uuid($uuid_bin);
}

sub config {
my $self = shift;
my ($setting, @val) = @_;
Expand Down
94 changes: 94 additions & 0 deletions lib/App/Yath/Schema/MariaDB/ApiKey.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
use utf8;
package App::Yath::Schema::MariaDB::ApiKey;
our $VERSION = '2.000000';

package
App::Yath::Schema::Result::ApiKey;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY ANY PART OF THIS FILE

use strict;
use warnings;

use parent 'App::Yath::Schema::ResultBase';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
"UUIDColumns",
);
__PACKAGE__->table("api_keys");
__PACKAGE__->add_columns(
"value",
{ data_type => "uuid", is_nullable => 0 },
"api_key_id",
{ data_type => "bigint", is_auto_increment => 1, is_nullable => 0 },
"user_id",
{ data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
"status",
{
data_type => "enum",
default_value => "active",
extra => { list => ["active", "disabled", "revoked"] },
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 128 },
);
__PACKAGE__->set_primary_key("api_key_id");
__PACKAGE__->add_unique_constraint("value", ["value"]);
__PACKAGE__->belongs_to(
"user",
"App::Yath::Schema::Result::User",
{ user_id => "user_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
);


# Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-06-03 19:08:09
# DO NOT MODIFY ANY PART OF THIS FILE

1;

__END__
=pod
=encoding UTF-8
=head1 NAME
App::Yath::Schema::MariaDB::ApiKey - Autogenerated result class for ApiKey in MariaDB.
=head1 SOURCE
The source code repository for Test2-Harness can be found at
L<http://github.com/Test-More/Test2-Harness/>.
=head1 MAINTAINERS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright Chad Granum E<lt>exodist7@gmail.comE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://dev.perl.org/licenses/>
=cut
97 changes: 97 additions & 0 deletions lib/App/Yath/Schema/MariaDB/Binary.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
use utf8;
package App::Yath::Schema::MariaDB::Binary;
our $VERSION = '2.000000';

package
App::Yath::Schema::Result::Binary;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY ANY PART OF THIS FILE

use strict;
use warnings;

use parent 'App::Yath::Schema::ResultBase';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
"UUIDColumns",
);
__PACKAGE__->table("binaries");
__PACKAGE__->add_columns(
"event_uuid",
{ data_type => "uuid", is_nullable => 0 },
"binary_id",
{ data_type => "bigint", is_auto_increment => 1, is_nullable => 0 },
"event_id",
{ data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
"is_image",
{ data_type => "tinyint", default_value => 0, is_nullable => 0 },
"filename",
{ data_type => "varchar", is_nullable => 0, size => 512 },
"description",
{ data_type => "text", is_nullable => 1 },
"data",
{ data_type => "longblob", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("binary_id");
__PACKAGE__->belongs_to(
"event",
"App::Yath::Schema::Result::Event",
{ event_id => "event_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "RESTRICT",
},
);


# Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-06-03 19:08:09
# DO NOT MODIFY ANY PART OF THIS FILE

1;

__END__
=pod
=encoding UTF-8
=head1 NAME
App::Yath::Schema::MariaDB::Binary - Autogenerated result class for Binary in MariaDB.
=head1 SOURCE
The source code repository for Test2-Harness can be found at
L<http://github.com/Test-More/Test2-Harness/>.
=head1 MAINTAINERS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright Chad Granum E<lt>exodist7@gmail.comE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://dev.perl.org/licenses/>
=cut
79 changes: 79 additions & 0 deletions lib/App/Yath/Schema/MariaDB/Config.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use utf8;
package App::Yath::Schema::MariaDB::Config;
our $VERSION = '2.000000';

package
App::Yath::Schema::Result::Config;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY ANY PART OF THIS FILE

use strict;
use warnings;

use parent 'App::Yath::Schema::ResultBase';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
"UUIDColumns",
);
__PACKAGE__->table("config");
__PACKAGE__->add_columns(
"config_id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"setting",
{ data_type => "varchar", is_nullable => 0, size => 128 },
"value",
{ data_type => "varchar", is_nullable => 0, size => 256 },
);
__PACKAGE__->set_primary_key("config_id");
__PACKAGE__->add_unique_constraint("setting", ["setting"]);


# Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-06-03 19:08:09
# DO NOT MODIFY ANY PART OF THIS FILE

1;

__END__
=pod
=encoding UTF-8
=head1 NAME
App::Yath::Schema::MariaDB::Config - Autogenerated result class for Config in MariaDB.
=head1 SOURCE
The source code repository for Test2-Harness can be found at
L<http://github.com/Test-More/Test2-Harness/>.
=head1 MAINTAINERS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright Chad Granum E<lt>exodist7@gmail.comE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://dev.perl.org/licenses/>
=cut
Loading

0 comments on commit 0028ffc

Please sign in to comment.