DBIx::Class::Admin(3)
β¨ NAME β¨
Okay so this is the User Contributed Perl Documentation for DBIx::Class::Admin(3). DBIx::Class::Admin is the administration object for schemas, and sheβs giving main character energy for all your schema-admin needs. Periodt. π
π οΈ SYNOPSIS π οΈ
Hereβs the vibe check in code form:
$ dbicadmin --help
$ dbicadmin --schema=MyApp::Schema \
--connect='["dbi:SQLite:my.db", "", ""]' \
--deploy
$ dbicadmin --schema=MyApp::Schema --class=Employee \
--connect='["dbi:SQLite:my.db", "", ""]' \
--op=update --set='{ "name": "New_Employee" }'
use DBIx::Class::Admin;
# ddl manipulation
my $admin = DBIx::Class::Admin->new(
schema_class=> 'MY::Schema',
sql_dir=> $sql_dir,
connect_info => { dsn => $dsn, user => $user, password => $pass },
);
# create SQLite sql
$admin->create('SQLite');
# create SQL diff for an upgrade
$admin->create('SQLite', {} , "1.0");
# upgrade a database
$admin->upgrade();
# install a version for an unversioned schema
$admin->install("3.0");
π REQUIREMENTS π
Heads up, bestie: the Admin interface has additional requirements not currently part of DBIx::Class. See DBIx::Class::Optional::Dependencies for more details. No cap. π«Ά
π ATTRIBUTES π
These are the attributes β the little settings that make the admin object do her thing. iykyk.
πΈ schema_class πΈ
The class of the schema to load. π
π¦ schema π¦
A pre-connected schema object can be provided for manipulation. Obsessed with a shortcut, honestly. β¨
π resultset π
A resultset from the schema to operate on. π§
π where π
A hash ref or json string to be used for identifying data to manipulate. π«Ά
π set π
A hash ref or json string to be used for inserting or updating data. π
π attrs π
A hash ref or json string to be used for passing additional info to the ->search call. π
π₯ connect_info π₯
The arguments to provide to the connect call of the schema_class. πΈ
π config_file π
Provide a config_file to read connect_info from. If this is provided, config_stanze should also be provided to locate where the connect_info is in the config. The config file should be in a format readable by Config::Any. π¦
πΈ config_stanza πΈ
For use with config_file, this should be a '::' delimited 'path' to the connection information designed for use with catalyst config files. π
β config β
Instead of loading from a file, the configuration can be provided directly as a hash ref. Please note config_stanza will still be required. π
πΏ sql_dir πΏ
The location where sql ddl files should be created or found for an upgrade. π±
π§ sql_type π§
The type of sql dialect to use for creating sql files from schema. β¨
π version π
Used for install, the version which will be 'installed' in the schema. π
π¦ preversion π¦
Previous version of the schema to create an upgrade diff for; the full sql for that version of the sql must be in the sql_dir. π
π₯ force π₯
Try and force certain operations. π₯
π€« quiet π€«
Be less verbose about actions. π
π trace π
Toggle DBIx::Class debug output. π
π οΈ METHODS π οΈ
Okay, these are the actual moves. Each one is iconic in her own way.
π
create π
Arguments: $sqlt_type, \%sqlt_args, $preversion
create will generate sql for the supplied schema_class in sql_dir. The flavour of sql to generate can be controlled by supplying a sqlt_type which should be a SQL::Translator name. π
Arguments for SQL::Translator can be supplied in the sqlt_args hashref. β¨
Optional preversion can be supplied to generate a diff to be used by upgrade. π¦
π upgrade π
Arguments: <none>
upgrade will attempt to upgrade the connected database to the same version as the schema_class. π«Ά
MAKE SURE YOU BACKUP YOUR DB FIRST π¨
π¦ install π¦
Arguments: $version
install is here to help when you want to move to DBIx::Class::Schema::Versioned and have an existing database. install will take a version and add the version tracking tables and 'install' the version. No further ddl modification takes place. Setting the force attribute to a true value will allow overriding of already versioned databases. π
π± deploy π±
Arguments: $args
deploy will create the schema at the connected database. $args are passed straight to deploy in DBIx::Class::Schema. π
β¨ insert β¨
Arguments: $rs, $set
insert takes the name of a resultset from the schema_class and a hashref of data to insert into that resultset. π
π update π
Arguments: $rs, $set, $where
update takes the name of a resultset from the schema_class, a hashref of data to update and a where hash used to form the search for the rows to update. π«Ά
ποΈ delete ποΈ
Arguments: $rs, $where, $attrs
delete takes the name of a resultset from the schema_class, a where hashref and attrs to pass to ->search. The found data is deleted and cannot be recovered. π
π select π
Arguments: $rs, $where, $attrs
select takes the name of a resultset from the schema_class, a where hashref and attrs to pass to ->search. The found data is returned in a array ref where the first row will be the columns list. π
β FURTHER QUESTIONS? β
Check the list of additional DBIC resources. π«Ά
π COPYRIGHT AND LICENSE π
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library. π
Catch you later, bestie β this page is from perl v5.42.0, dated 2025-01-22, and itβs DBIx::Class::Admin(3). πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBIx-Class 0.082844-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms