setForceUpdate() публичный Метод

public setForceUpdate ( $force = true )
Пример #1
0
 public function execute()
 {
     $logger = $this->getLogger();
     $config = $this->getConfigLoader();
     $this->logger->debug('Finding schemas...');
     $classes = $this->findSchemasByArguments(func_get_args());
     SchemaUtils::printSchemaClasses($classes, $this->logger);
     $this->logger->debug("Initializing schema generator...");
     $generator = new SchemaGenerator($config, $this->logger);
     if ($this->options->force) {
         $generator->setForceUpdate(true);
     }
     $classMap = $generator->generate($classes, $this->options->force);
     /*
     foreach( $classMap as $class => $file ) {
         $path = $file;
         if ( strpos( $path , getcwd() ) === 0 ) {
             $path = substr( $path , strlen(getcwd()) + 1 );
         }
         $logger->info($path);
         // $logger->info(sprintf("%-32s",ltrim($class,'\\')) . " => $path",1);
     }
     */
     $logger->info('Done');
 }
Пример #2
0
 public function testSchemaGenerator()
 {
     $g = new SchemaGenerator($this->config, $this->logger);
     $g->setForceUpdate(true);
     $schemas = $this->getModels();
     foreach ($schemas as $schema) {
         if ($result = $g->generateCollectionClass($schema)) {
             list($class, $file) = $result;
             ok($class);
             ok($file);
             path_ok($file);
             $this->syntaxTest($file);
         }
         if ($classMap = $g->generate(array($schema))) {
             foreach ($classMap as $class => $file) {
                 ok($class);
                 ok($file);
                 path_ok($file, $file);
                 // $this->syntaxTest($file);
                 require_once $file;
             }
         }
         $pk = $schema->findPrimaryKey();
         $this->assertNotNull($pk, "Find primary key from " . get_class($schema));
         $model = $schema->newModel();
         $this->assertNotNull($model);
         $collection = $schema->newCollection();
         $this->assertNotNull($collection);
     }
 }
Пример #3
0
 public function execute()
 {
     $args = func_get_args();
     $logger = $this->getLogger();
     $config = $this->getConfigLoader(true);
     $this->logger->debug('Finding schemas...');
     $schemas = SchemaUtils::findSchemasByArguments($config, $args, $logger);
     $generator = new SchemaGenerator($config);
     if ($this->options->force) {
         $generator->setForceUpdate(true);
     }
     $classMap = array();
     foreach ($schemas as $schema) {
         if ($this->logger->isDebug()) {
             $this->logger->debug('Checking ' . get_class($schema));
         }
         $generated = $generator->generateSchemaFiles($schema);
         if (!empty($generated)) {
             if ($this->logger->isDebug()) {
                 // $filepath = str_replace(getcwd().'/', '', $schema->getClassFileName());
                 $this->logger->debug('Updated ' . get_class($schema));
                 foreach ($generated as $class => $file) {
                     $this->logger->debug(' - Updated ' . $file);
                 }
             } else {
                 $this->logger->info('Updated ' . get_class($schema));
             }
             $classMap += $generated;
         }
     }
 }
Пример #4
0
 public function setUp()
 {
     if ($this->onlyDriver !== null && $this->getDataSource() != $this->onlyDriver) {
         return $this->markTestSkipped("{$this->onlyDriver} only");
     }
     $this->prepareConnection();
     // Ensure that we use the correct default data source ID
     $this->assertEquals($this->getDataSource(), $this->config->getDefaultDataSourceId());
     $this->assertInstanceOf('SQLBuilder\\Driver\\BaseDriver', $this->queryDriver, 'QueryDriver object OK');
     // Rebuild means rebuild the database for new tests
     $annnotations = $this->getAnnotations();
     $rebuild = true;
     $basedata = true;
     if (isset($annnotations['method']['rebuild'][0]) && $annnotations['method']['rebuild'][0] == 'false') {
         $rebuild = false;
     }
     if (isset($annnotations['method']['basedata'][0]) && $annnotations['method']['basedata'][0] == 'false') {
         $basedata = false;
     }
     $schemas = ClassUtils::schema_classes_to_objects($this->getModels());
     if (false === $this->schemaHasBeenBuilt) {
         $g = new SchemaGenerator($this->config);
         $g->setForceUpdate(true);
         $g->generate($schemas);
         $this->schemaHasBeenBuilt = true;
     }
     if ($rebuild === false) {
         $tableParser = TableParser::create($this->conn, $this->queryDriver, $this->config);
         $tables = $tableParser->getTables();
         $schemas = array_filter($schemas, function ($schema) use($tables) {
             return !in_array($schema->getTable(), $tables);
         });
     }
     $this->sqlBuilder = SqlBuilder::create($this->queryDriver, array('rebuild' => $rebuild));
     $this->bootstrap = new Bootstrap($this->conn, $this->sqlBuilder, $this->logger);
     $this->bootstrap->build($schemas);
     if ($rebuild && $basedata) {
         $seeder = new SeedBuilder($this->logger);
         $seeder->build(new SchemaCollection($schemas));
         $seeder->buildConfigSeeds($this->config);
     }
 }
Пример #5
0
<?php

$loader = (require "vendor/autoload.php");
require "tests/model_helpers.php";
mb_internal_encoding('UTF-8');
error_reporting(E_ALL);
$loader->add(null, 'tests');
$loader->add(null, 'tests/src');
use LazyRecord\Schema\SchemaGenerator;
use LazyRecord\ConfigLoader;
use CLIFramework\Logger;
$config = ConfigLoader::getInstance();
$config->loadFromSymbol(true);
$config->initForBuild();
$logger = new Logger();
$logger->quiet();
$logger->info("Building schema class files...");
// build schema class files
$schemas = array(new \AuthorBooks\Model\AddressSchema(), new \AuthorBooks\Model\AuthorBookSchema(), new \AuthorBooks\Model\AuthorSchema(), new \AuthorBooks\Model\BookSchema(), new \AuthorBooks\Model\PublisherSchema(), new \AuthorBooks\Model\TagSchema(), new \MetricApp\Model\MetricValueSchema(), new \PageApp\Model\PageSchema(), new \StoreApp\Model\StoreSchema(), new \TestApp\Model\EdmSchema(), new \TestApp\Model\IDNumberSchema(), new \TestApp\Model\NameSchema(), new \TestApp\Model\PostSchema(), new \TestApp\Model\TableSchema(), new \TestApp\Model\UserSchema(), new \TestApp\Model\WineCategorySchema(), new \TestApp\Model\WineSchema());
$g = new \LazyRecord\Schema\SchemaGenerator($config, $logger);
$g->setForceUpdate(true);
$g->generate($schemas, true);
// $logger->info("Starting tests...");