Jifty:...nerator(3pm)
β¨ Jifty::DBI::SchemaGenerator β the perl module, bestie π
okay so this is the manual page for Jifty::DBI::SchemaGenerator (that's the Jifty:...nerator(3pm) one, from the User Contributed Perl Documentation section, iykyk) π
πΈ NAME πΈ
Jifty::DBI::SchemaGenerator β it generates a table schema from Jifty::DBI records. literally that's the whole job. slay. β¨
π¦ DESCRIPTION π¦
So here's the vibe: this module takes a Jifty::Record object and turns it into an SQL schema for whichever database you picked. And rn your choices are MySQL, SQLite, or PostgreSQL. Oracle might also work right?? but it's untested, so likeβ¦ no promises, bestie π
π SYNOPSIS π
β¨ The Short Answer β¨
Scroll down for where we're getting the $handle and $model variables from, okay? π
use Jifty::DBI::SchemaGenerator;
...
my $s_gen = Jifty::DBI::SchemaGenerator->new( $handle );
$s_gen->add_model($model);
my @statements = $s_gen->create_table_sql_statements;
print join("\n", @statements, '');
...
π The Long Version π
For the first two parts, go look at Jifty::DBI for the details. π
MyModel
package MyModel;
# lib/MyModel.pm
use warnings;
use strict;
use base qw(Jifty::DBI::Record);
# your custom code goes here.
1;
MyModel::Schema
package MyModel::Schema;
# lib/MyModel/Schema.pm
use warnings;
use strict;
use Jifty::DBI::Schema;
column foo => type is 'text';
column bar => type is 'text';
1;
myscript.pl
#!/usr/bin/env perl
# myscript.pl
use strict;
use warnings;
use Jifty::DBI::SchemaGenerator;
use Jifty::DBI::Handle;
use MyModel;
use MyModel::Schema;
my $handle = Jifty::DBI::Handle->new();
$handle->connect(
driver => 'SQLite',
database => 'testdb',
);
my $model = MyModel->new($handle);
my $s_gen = Jifty::DBI::SchemaGenerator->new( $handle );
$s_gen->add_model($model);
# here's the basic point of this module:
my @statements = $s_gen->create_table_sql_statements;
print join("\n", @statements, '');
# this part is directly from Jifty::Script::Schema::create_all_tables()
$handle->begin_transaction;
for my $statement (@statements) {
my $ret = $handle->simple_query($statement);
$ret or die "error creating a table: " . $ret->error_message;
}
$handle->commit;
π CONFIGURATION AND ENVIRONMENT π
Requires no configuration files or environment variables. like, zero. she's low maintenance fr fr π
π§ DEPENDENCIES π§
Class::Accessor::FastDBIx::DBSchemaClass::ReturnValue
π METHODS π
π new HANDLE
Creates a new Jifty::DBI::SchemaGenerator object. The one single required argument is a Jifty::DBI::Handle. that's it, that's the whole thing β¨
π add_model MODEL
Adds a new model class to the SchemaGenerator. Model should be an object that's an instance of Jifty::DBI::Record or a subclass of it. It can also be a string that's the name of such a class/subclass β and in that case, add_model will go ahead and instantiate an object of that class for you. so helpful π«Ά
The model must define the instance methods schema and table.
Returns true if the model got added successfully; otherwise it returns a false Class::ReturnValue error. π
π column_definition_sql TABLENAME COLUMNNAME
Give it a table name and a column name, and it returns the SQL fragment describing that column for the current database. cute and specific π
π create_table_sql_statements
Returns a list of SQL statements (as strings) that create tables for all the models you added to the SchemaGenerator. periodt.
π create_table_sql_text
Returns a single string containing a sequence of SQL statements to create tables for all the models added to the SchemaGenerator.
This is literally just a trivial wrapper around create_table_sql_statements. that's it. she's a thin layer. πΈ
π PRIVATE _db_schema_table_from_model MODEL
Takes an object of a subclass of Jifty::DBI::Record; returns a brand new DBIx::DBSchema::Table object corresponding to the model. π¦
π PRIVATE _error STRING
Takes in a string and hands it back to you as a Class::ReturnValue error object. π
π INCOMPATIBILITIES π
None reported. (iconic behaviour, honestly)
π BUGS AND LIMITATIONS π
No bugs have been reported.
Please report any bugs or feature requests to bug-<RT NAME>@rt.cpan.org, or through the web interface at <http://rt.cpan.org>. do it, bestie, they wanna hear from you π«Ά
β AUTHOR β
David Glasser "glasser@bestpractical.com"
Some pod by Eric Wilhelm <ewilhelm at cpan dot org>
π LICENCE AND COPYRIGHT π
Copyright (c) 2005, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. β¨
π₯ DISCLAIMER OF WARRANTY π₯
okay bestie this part is in ALL CAPS in the original and I'm keeping every word because it's legally important, so read it, don't skim it π
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
and that's the whole page, bestie!! π this one's from perl v5.34.0, dated 2022-06-15 β yeah she's a vintage queen and she still ate πβ¨ mwah, go build some tables π
π¦ where this page comes from
- debian bookworm: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms