-
Notifications
You must be signed in to change notification settings - Fork 7
schema:parse
This function parses an existing XML schema file and creates the corresponding ORM PHP classes. Use this function when you have changed your database schema (e.g. added tables or columns). This corresponds to the parseSchema()
method of the xPDO generator class.
php repoman schema:parse <pkg_root_dir> --model=<model-name> [options]
--model
: (string, defaults to namespace)
Specifies 1) which XML schema file is to be parsed by the stub name and 2) the name of the sub-directory inside $orm_path
where the corresponding PHP files will be written. E.g. assuming the default $orm_path, then "--model=foobar" would cause the model/schema/foobar.mysql.schema.xml
to be parsed and the corresponding PHP classes to be generated inside of model/foobar/
--orm_path
: (string, defaults to "model/")
Identifies the parent folder (relative to package root) where sub-folders for the various models and for "schema/". Specify a custom value if your project is significantly complex enough to merit organization that goes beyond the default value.
--table_prefix
: (string, optional)
The table name prefix used to identify a sub-set of tables.
--overwrite
(mixed: true|false|force)
This controls how conflicting files are handled. When false (i.e. not set), the script behaves cowardly and will exit if any conflict is detected. When true, the script will attempt to politely rename any conflicting files with a name corresponding to the Unix timestamp: these files should be manually reviewed. If you find yourself frequently restoring a timestamped version of a file, see the --restore
option. Using the "force" option will delete any conflicting files: use with extreme caution! Default: false.
--restore
: (comma-separated string, optional)
You can list patterns here for the basenames of class files that should be restored after being politely
renamed with a Unix timestamp. This is useful when you are re-parsing a schema repeatedly to fine-tune
validation rules and you want to preserve custom resource classes (perhaps these should live in their own
model?) or when you need to regenerate some classes but leave others alone (e.g. those with extensive
customizations). Do not restore "mysql": that's usually the one directory you want xPDO to generate for you.
--restrict_prefix
: (boolean, optional) Normally you want to only write schema corresponding to the
tables with the given table_prefix, but you can ignore this restriction by setting this to false.
Default: true.
--dir_perms
: (optional) the permissions mask to use if it is necessary to create directories.
The global default is 0777, and it should rarely need to be changed: permissions are best
left defined by the parent environment not forced by this script.
Parse the XML file located at model/schema/mypre.mysql.schema.xml
into classfiles.
php repoman.php schema:parse <pkg_root_dir> --table_prefix=mypre_ --model=mypkg
Attempt to rename files during the operation:
php repoman.php schema:parse <pkg_root_dir> --action=parse --table_prefix=mypre_ --model=mypkg
It's not uncommon for a warning to be generated when running this:
(WARN @ repoman) Could not load package metadata for package ____
This can be safely ignored.
© 2014 and beyond by Craftsman Coding