1DBIx::Class::Admin(3) User Contributed Perl DocumentationDBIx::Class::Admin(3)
2
3
4

NAME

6       DBIx::Class::Admin - Administration object for schemas
7

SYNOPSIS

9         $ dbicadmin --help
10
11         $ dbicadmin --schema=MyApp::Schema \
12           --connect='["dbi:SQLite:my.db", "", ""]' \
13           --deploy
14
15         $ dbicadmin --schema=MyApp::Schema --class=Employee \
16           --connect='["dbi:SQLite:my.db", "", ""]' \
17           --op=update --set='{ "name": "New_Employee" }'
18
19         use DBIx::Class::Admin;
20
21         # ddl manipulation
22         my $admin = DBIx::Class::Admin->new(
23           schema_class=> 'MY::Schema',
24           sql_dir=> $sql_dir,
25           connect_info => { dsn => $dsn, user => $user, password => $pass },
26         );
27
28         # create SQLite sql
29         $admin->create('SQLite');
30
31         # create SQL diff for an upgrade
32         $admin->create('SQLite', {} , "1.0");
33
34         # upgrade a database
35         $admin->upgrade();
36
37         # install a version for an unversioned schema
38         $admin->install("3.0");
39

REQUIREMENTS

41       The Admin interface has additional requirements not currently part of
42       DBIx::Class. See DBIx::Class::Optional::Dependencies for more details.
43

ATTRIBUTES

45   schema_class
46       the class of the schema to load
47
48   schema
49       A pre-connected schema object can be provided for manipulation
50
51   resultset
52       a resultset from the schema to operate on
53
54   where
55       a hash ref or json string to be used for identifying data to manipulate
56
57   set
58       a hash ref or json string to be used for inserting or updating data
59
60   attrs
61       a hash ref or json string to be used for passing additional info to the
62       ->search call
63
64   connect_info
65       connect_info the arguments to provide to the connect call of the
66       schema_class
67
68   config_file
69       config_file provide a config_file to read connect_info from, if this is
70       provided config_stanze should also be provided to locate where the
71       connect_info is in the config The config file should be in a format
72       readable by Config::Any.
73
74   config_stanza
75       config_stanza for use with config_file should be a '::' delimited
76       'path' to the connection information designed for use with catalyst
77       config files
78
79   config
80       Instead of loading from a file the configuration can be provided
81       directly as a hash ref.  Please note config_stanza will still be
82       required.
83
84   sql_dir
85       The location where sql ddl files should be created or found for an
86       upgrade.
87
88   sql_type
89       The type of sql dialect to use for creating sql files from schema
90
91   version
92       Used for install, the version which will be 'installed' in the schema
93
94   preversion
95       Previous version of the schema to create an upgrade diff for, the full
96       sql for that version of the sql must be in the sql_dir
97
98   force
99       Try and force certain operations.
100
101   quiet
102       Be less verbose about actions
103
104   trace
105       Toggle DBIx::Class debug output
106

METHODS

108   create
109       Arguments: $sqlt_type, \%sqlt_args, $preversion
110
111       "create" will generate sql for the supplied schema_class in sql_dir.
112       The flavour of sql to generate can be controlled by supplying a
113       sqlt_type which should be a SQL::Translator name.
114
115       Arguments for SQL::Translator can be supplied in the sqlt_args hashref.
116
117       Optional preversion can be supplied to generate a diff to be used by
118       upgrade.
119
120   upgrade
121       Arguments: <none>
122
123       upgrade will attempt to upgrade the connected database to the same
124       version as the schema_class.  MAKE SURE YOU BACKUP YOUR DB FIRST
125
126   install
127       Arguments: $version
128
129       install is here to help when you want to move to
130       DBIx::Class::Schema::Versioned and have an existing database.  install
131       will take a version and add the version tracking tables and 'install'
132       the version.  No further ddl modification takes place.  Setting the
133       force attribute to a true value will allow overriding of already
134       versioned databases.
135
136   deploy
137       Arguments: $args
138
139       deploy will create the schema at the connected database.  $args are
140       passed straight to "deploy" in DBIx::Class::Schema.
141
142   insert
143       Arguments: $rs, $set
144
145       insert takes the name of a resultset from the schema_class and a
146       hashref of data to insert into that resultset
147
148   update
149       Arguments: $rs, $set, $where
150
151       update takes the name of a resultset from the schema_class, a hashref
152       of data to update and a where hash used to form the search for the rows
153       to update.
154
155   delete
156       Arguments: $rs, $where, $attrs
157
158       delete takes the name of a resultset from the schema_class, a where
159       hashref and a attrs to pass to ->search.  The found data is deleted and
160       cannot be recovered.
161
162   select
163       Arguments: $rs, $where, $attrs
164
165       select takes the name of a resultset from the schema_class, a where
166       hashref and a attrs to pass to ->search.  The found data is returned in
167       a array ref where the first row will be the columns list.
168

FURTHER QUESTIONS?

170       Check the list of additional DBIC resources.
171
173       This module is free software copyright by the DBIx::Class (DBIC)
174       authors. You can redistribute it and/or modify it under the same terms
175       as the DBIx::Class library.
176
177
178
179perl v5.30.1                      2020-01-29             DBIx::Class::Admin(3)
Impressum