| 1 | package DBIO::MySQL::Deploy; | ||
| 2 | # ABSTRACT: Deploy and upgrade MySQL/MariaDB schemas via test-deploy-and-compare | ||
| 3 | |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use base 'DBIO::Deploy::Base::TempDatabase'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | use DBIO::MySQL::DDL (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use DBIO::MySQL::Introspect (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use DBIO::MySQL::Diff (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | # The three class-name hooks DBIO::Deploy::Base needs. | ||
| 14 | |||
| 15 | 0 | ▶ | sub _ddl_class { 'DBIO::MySQL::DDL' } |
|
Subroutine
_ddl_class: not called CC=1 SCAR=6.9
| |||
| 16 | 0 | ▶ | sub _introspect_class { 'DBIO::MySQL::Introspect' } |
|
Subroutine
_introspect_class: not called CC=1 SCAR=6.9
| |||
| 17 | 0 | ▶ | sub _diff_class { 'DBIO::MySQL::Diff' } |
|
Subroutine
_diff_class: not called CC=1 SCAR=6.9
| |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | # --- MySQL-specific temp-database dialect --- | ||
| 22 | |||
| 23 | 0 | ▶ | sub _create_temp_db { |
|
Subroutine
_create_temp_db: not called CC=1 SCAR=6.9
| |||
| 24 | 0 | my ($self, $dbh) = @_; | |
| 25 | 0 | my $name = $self->temp_db_prefix . $$ . '_' . time(); | |
| 26 | 0 | $dbh->do(sprintf 'CREATE DATABASE `%s`', $name); | |
| 27 | 0 | return $name; | |
| 28 | } | ||
| 29 | |||
| 30 | 0 | ▶ | sub _drop_temp_db { |
|
Subroutine
_drop_temp_db: not called CC=1 SCAR=6.9
| |||
| 31 | 0 | my ($self, $dbh, $name) = @_; | |
| 32 | 0 | $dbh->do(sprintf 'DROP DATABASE IF EXISTS `%s`', $name); | |
| 33 | } | ||
| 34 | |||
| 35 | 1 | 1; | |
| 36 | |||
| 37 | __END__ | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =encoding UTF-8 | ||
| 42 | |||
| 43 | =head1 NAME | ||
| 44 | |||
| 45 | DBIO::MySQL::Deploy - Deploy and upgrade MySQL/MariaDB schemas via test-deploy-and-compare | ||
| 46 | |||
| 47 | =head1 VERSION | ||
| 48 | |||
| 49 | version 0.900001 | ||
| 50 | |||
| 51 | =head1 DESCRIPTION | ||
| 52 | |||
| 53 | C<DBIO::MySQL::Deploy> orchestrates the deployment and upgrade of | ||
| 54 | MySQL/MariaDB schemas using a test-deploy-and-compare strategy: it | ||
| 55 | deploys the desired schema into a freshly created temporary | ||
| 56 | C<CREATE DATABASE> database, introspects it, and diffs the result | ||
| 57 | against the live database. See L<DBIO::Deploy::Base> for the shared | ||
| 58 | install/apply/upgrade flow; see L<DBIO::Deploy::Base::TempDatabase> | ||
| 59 | for the temp-database orchestration this driver inherits. | ||
| 60 | |||
| 61 | my $deploy = DBIO::MySQL::Deploy->new( | ||
| 62 | schema => MyApp::DB->connect($dsn, $user, $pass), | ||
| 63 | ); | ||
| 64 | |||
| 65 | $deploy->install; # fresh install | ||
| 66 | $deploy->upgrade; # diff + apply | ||
| 67 | |||
| 68 | =head1 ATTRIBUTES | ||
| 69 | |||
| 70 | =head2 temp_db_prefix | ||
| 71 | |||
| 72 | Prefix for temporary databases created during C<diff>. Defaults to | ||
| 73 | C<_dbio_tmp_>. The full name includes the PID and current timestamp. | ||
| 74 | Inherited from L<DBIO::Deploy::Base::TempDatabase>. | ||
| 75 | |||
| 76 | =over 4 | ||
| 77 | |||
| 78 | =item * L<DBIO::MySQL> | ||
| 79 | |||
| 80 | =item * L<DBIO::MySQL::DDL> | ||
| 81 | |||
| 82 | =item * L<DBIO::MySQL::Introspect> | ||
| 83 | |||
| 84 | =item * L<DBIO::MySQL::Diff> | ||
| 85 | |||
| 86 | =item * L<DBIO::PostgreSQL::Deploy> - the PostgreSQL counterpart | ||
| 87 | |||
| 88 | =item * L<DBIO::SQLite::Deploy> - the SQLite counterpart | ||
| 89 | |||
| 90 | =back | ||
| 91 | |||
| 92 | =head1 AUTHOR | ||
| 93 | |||
| 94 | DBIO & DBIx::Class Authors | ||
| 95 | |||
| 96 | =head1 COPYRIGHT AND LICENSE | ||
| 97 | |||
| 98 | Copyright (C) 2026 DBIO Authors | ||
| 99 | Portions Copyright (C) 2005-2025 DBIx::Class Authors | ||
| 100 | Based on DBIx::Class, heavily modified. | ||
| 101 | |||
| 102 | This is free software; you can redistribute it and/or modify it under | ||
| 103 | the same terms as the Perl 5 programming language system itself. | ||
| 104 | |||
| 105 | =cut | ||