Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore current schema on initialize function #1255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

/composer.lock
/vendor
.idea
2 changes: 1 addition & 1 deletion scripts/Phalcon/Builder/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function build()
$schema = Utils::resolveDbSchema($config->database);
}

if ($schema) {
if ($schema && !$this->modelOptions->getOption('noInitSchema')) {
$initialize['schema'] = $snippet->getThisMethod('setSchema', $schema);
}
$initialize['source'] = $snippet->getThisMethod('setSource', $this->modelOptions->getOption('name'));
Expand Down
2 changes: 2 additions & 0 deletions scripts/Phalcon/Commands/Builtin/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function getPossibleParams()
return [
'name=s' => 'Table name',
'schema=s' => 'Name of the schema [optional]',
'no-init-schema' => 'Do not add schema into initialize function [optional]',
'config=s' => 'Configuration file [optional]',
'namespace=s' => "Model's namespace [optional]",
'get-set' => 'Attributes will be protected and have setters/getters [optional]',
Expand Down Expand Up @@ -84,6 +85,7 @@ public function run(array $parameters)
'config' => $this->getConfigObject(),
'className' => $className,
'fileName' => Text::uncamelize($className),
'noInitSchema' => $this->isReceivedOption('no-init-schema'),
'genSettersGetters' => $this->isReceivedOption('get-set'),
'genDocMethods' => $this->isReceivedOption('doc'),
'namespace' => $this->getOption('namespace'),
Expand Down