/** * Perform schema reflection to database(s). All declared tables will created or altered. Only * tables linked to non abstract records and record with active schema parameter will be * executed. * * SchemaBuilder will not allow (SchemaException) to create or alter tables columns declared * by abstract or records with ACTIVE_SCHEMA constant set to false. ActiveSchema still can * declare foreign keys and indexes (most of relations automatically request index or foreign * key), but they are going to be ignored. * * Due principals of database schemas and ORM component logic no data or columns will ever be * removed from database. In addition column renaming will cause creation of another column. * * Use database migrations to solve more complex database questions. Or disable ACTIVE_SCHEMA * and live like normal people. * * @throws SchemaException * @throws \Spiral\Database\Exceptions\SchemaException * @throws \Spiral\Database\Exceptions\QueryException * @throws \Spiral\Database\Exceptions\DriverException */ public function synchronizeSchema() { $bus = new SynchronizationBus($this->getTables()); $bus->syncronize(); }
/** * Perform schema reflection to database(s). All declared tables will created or altered. Only * tables linked to non abstract records and record with active schema parameter will be * executed. * * SchemaBuilder will not allow (SchemaException) to create or alter tables columns declared * by abstract or records with ACTIVE_SCHEMA constant set to false. ActiveSchema still can * declare foreign keys and indexes (most of relations automatically request index or foreign * key), but they are going to be ignored. * * Due principals of database schemas and ORM component logic no data or columns will ever be * removed from database. In addition column renaming will cause creation of another column. * * Use database migrations to solve more complex database questions. Or disable ACTIVE_SCHEMA * and live like normal people. * * @throws SchemaException * @throws \Spiral\Database\Exceptions\SchemaException * @throws \Spiral\Database\Exceptions\QueryException * @throws \Spiral\Database\Exceptions\DriverException */ public function synchronizeSchema() { //As aternative you can get access to TableSchemas and generate needed migrations //@todo Phinx exporter module is needed $bus = new SynchronizationBus($this->getTables()); $bus->syncronize(); }