dbsrgits / dbix-class-schema-loader

Official GitHub remote for git.shadowcat.co.uk DBIx-Class-Schema-Loader.git
http://dbix-class.org/
11 stars 34 forks source link

Does not dump some relationships when using percona mysql #57

Open exodist opened 4 months ago

exodist commented 4 months ago

Relevent Schema:

CREATE TABLE runs (
    run_idx         BIGINT          NOT NULL AUTO_INCREMENT PRIMARY KEY,
    run_id          BINARY(16)      NOT NULL,
    [...]
    UNIQUE(run_id)
);

CREATE TABLE run_fields (
    run_field_idx   BIGINT          NOT NULL AUTO_INCREMENT PRIMARY KEY,
    run_id          BINARY(16)      NOT NULL,
    [...]
    FOREIGN KEY (run_id) REFERENCES runs(run_id) ON DELETE CASCADE
);

CREATE TABLE jobs (
    job_idx         BIGINT              NOT NULL AUTO_INCREMENT PRIMARY KEY,
    job_key         BINARY(16)          NOT NULL,
    [...]
    UNIQUE(job_key)
);

CREATE TABLE job_parameters (
    job_parameters_idx  BIGINT      NOT NULL AUTO_INCREMENT PRIMARY KEY,
    job_key             BINARY(16)  NOT NULL REFERENCES jobs(job_key) ON DELETE CASCADE,
    [...]
    UNIQUE(job_key)
);

When I load this into MariaDB and then dump the schema the xxx_parameter relationships dump fine, but when I load into Percona mysql they are omitted. Here are the diffs:

diff lib/App/Yath/Schema/MySQL/Run.pm lib/App/Yath/Schema/Percona/Run.pm                                                                                                                            
2c2
< package App::Yath::Schema::MySQL::Run;
---
> package App::Yath::Schema::Percona::Run;
54c54
<     default_value => "current_timestamp()",
---
>     default_value => \"current_timestamp",
131,136d130
< __PACKAGE__->might_have(
<   "run_parameter",
<   "App::Yath::Schema::Result::RunParameter",
<   { "foreign.run_id" => "self.run_id" },
<   { cascade_copy => 0, cascade_delete => 1 },
< );
151c145
< # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:33
---
> # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:39
166c160
< App::Yath::Schema::MySQL::Run - Autogenerated result class for Run in MySQL.
---
> App::Yath::Schema::Percona::Run - Autogenerated result class for Run in Percona.
diff lib/App/Yath/Schema/MySQL/Job.pm lib/App/Yath/Schema/Percona/Job.pm
2c2
< package App::Yath::Schema::MySQL::Job;
---
> package App::Yath::Schema::Percona::Job;
107,112d106
< __PACKAGE__->might_have(
<   "job_parameter",
<   "App::Yath::Schema::Result::JobParameter",
<   { "foreign.job_key" => "self.job_key" },
<   { cascade_copy => 0, cascade_delete => 1 },
< );
138c132
< # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:33
---
> # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:39
141d134
< __PACKAGE__->inflate_column('job_id' => { inflate => \&uuid_inflate, deflate => \&uuid_deflate });
142a136
> __PACKAGE__->inflate_column('job_id' => { inflate => \&uuid_inflate, deflate => \&uuid_deflate });
155c149
< App::Yath::Schema::MySQL::Job - Autogenerated result class for Job in MySQL.
---
> App::Yath::Schema::Percona::Job - Autogenerated result class for Job in Percona.
diff lib/App/Yath/Schema/MySQL/JobParameter.pm lib/App/Yath/Schema/Percona/JobParameter.pm
2c2
< package App::Yath::Schema::MySQL::JobParameter;
---
> package App::Yath::Schema::Percona::JobParameter;
27c27
<   { data_type => "binary", is_foreign_key => 1, is_nullable => 0, size => 16 },
---
>   { data_type => "binary", is_nullable => 0, size => 16 },
29c29
<   { data_type => "longtext", is_nullable => 1 },
---
>   { data_type => "json", is_nullable => 1 },
33,38d32
< __PACKAGE__->belongs_to(
<   "job",
<   "App::Yath::Schema::Result::Job",
<   { job_key => "job_key" },
<   { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
< );
41c35
< # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:33
---
> # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:39
56c50
< App::Yath::Schema::MySQL::JobParameter - Autogenerated result class for JobParameter in MySQL.
---
> App::Yath::Schema::Percona::JobParameter - Autogenerated result class for JobParameter in Percona.
diff lib/App/Yath/Schema/MySQL/RunParameter.pm lib/App/Yath/Schema/Percona/RunParameter.pm
2c2
< package App::Yath::Schema::MySQL::RunParameter;
---
> package App::Yath::Schema::Percona::RunParameter;
27c27
<   { data_type => "binary", is_foreign_key => 1, is_nullable => 0, size => 16 },
---
>   { data_type => "binary", is_nullable => 0, size => 16 },
29c29
<   { data_type => "longtext", is_nullable => 1 },
---
>   { data_type => "json", is_nullable => 1 },
33,38d32
< __PACKAGE__->belongs_to(
<   "run",
<   "App::Yath::Schema::Result::Run",
<   { run_id => "run_id" },
<   { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
< );
41c35
< # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:33
---
> # Created by DBIx::Class::Schema::Loader v0.07052 @ 2024-05-15 16:47:39
56c50
< App::Yath::Schema::MySQL::RunParameter - Autogenerated result class for RunParameter in MySQL.
---
> App::Yath::Schema::Percona::RunParameter - Autogenerated result class for RunParameter in Percona.

The only difference I am aware of is MariaDB vs Percona. I am happy to post the full schema and how I am generating things if that is necessary.

exodist commented 4 months ago

oh, also note binary(16) is used because percona does not yet support UUID fields.