Comments (21)
I don't think that migration should take place automatically every time you update or install bundles. Migration is something that should actively be monitored by the administrator and thus also be executed manually.
from installation-bundle.
A composer script handler certainly feels wrong. We should use Doctrine migrations anyway, but I'm not sure if that can easily be bundled in a library.
from installation-bundle.
I vote also against automatic database updates.
from installation-bundle.
It seems you all got the ticket wrong. I am not talking about schema updates, which should definitely not be automated. I am talking about the version updates (see the classes I have listed above); and those have been executed automatically in the install tool ever since.
from installation-bundle.
I'm very well aware of that. Still a composer script feels wrong, also because it would not be executed on deployment in most cases.
from installation-bundle.
I also wouldn’t expect a composer install or update to change my database. It may be better to print a warning on post-update-cmd
if the database is out of date.
from installation-bundle.
@aschempp why not, aren't you typically executing composer install
after deployment?
from installation-bundle.
@fritzmg depends on the deployment. You can also package your application with all vendor files and push it to the server(s).
from installation-bundle.
True, but then you need to update the database some other way anyway. e.g. By executing the install tool (I am assuming that functionality will still be present?)
from installation-bundle.
@fritzmg currently I am, but @leofeyer recommended post-update-cmd
which does not run on install. But your last comment says it all: there must be other ways to run that anyway.
from installation-bundle.
there must be other ways to run that anyway
Yes, app/console contao:run-version-updates
.
from installation-bundle.
Yeah, not sure about that…
from installation-bundle.
If that's the only way, then deployments without accessing the console will not be possible anymore. At least not without deploying the complete (updated) database as well.
from installation-bundle.
@aschempp So how do you run the version updates without opening the install tool after every deploy?
from installation-bundle.
I would keep the current behaviour of manually starting the migration via both ways.
- accessing the install tool
- executing
app/console contao:run-version-updates
Performing it automatically in post update feels wrong to me.
from installation-bundle.
from installation-bundle.
By running bin/console doctrine:schema:update ...
or when having orm and migrations bin/console app/console doctrine:migrations:migrate ...
We are, once again, in a special position as we do not define final entities in our application but are merely combining them "on the fly" due to our extension support. Therefore the approach of other projects does not really relate here.
from installation-bundle.
That would only update the schema, but not the database content. I'm pretty sure there are migrations for existing data in any of the big Symfony projects (http://symfony.com/en/projects).
from installation-bundle.
@aschempp Sorry but your previous statement is not true, it will migrate what you tell it to migrate, that is what the preUp
, postUp
, 'preDown' postDown
functions are for.
Pseudo code translation of src/Database/Version330Update.php
namespace Contao\CoreBundleBundle\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Bump contao database to 3.3.0
*/
class Version330Update extends AbstractMigration
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'mysql',
'Migration can only be executed safely on \'mysql\'.'
);
$this->abortIf(
!$this->connection->getSchemaManager()->tablesExist('tl_layout'),
'Table tl_layout not present.'
);
$columns = $schemaManager->listTableColumns('tl_layout');
$this->abortIf(isset($columns['viewport']), 'column viewport already present.');
}
/**
* @param Schema $schema
*/
public function postUp(Schema $schema) {
$statement = $this->connection->query("SELECT id, framework FROM tl_layout WHERE framework!=''");
while (false !== ($layout = $statement->fetch(\PDO::FETCH_OBJ))) {
$framework = '';
$tmp = \StringUtil::deserialize($layout->framework);
if (!empty($tmp) && is_array($tmp)) {
if (false !== ($key = array_search('layout.css', $tmp))) {
array_insert($tmp, $key + 1, 'responsive.css');
}
$framework = serialize(array_values(array_unique($tmp)));
}
$stmt = $this->connection->prepare('UPDATE tl_layout SET framework=:framework WHERE id=:id');
$stmt->execute([':framework' => $framework, ':id' => $layout->id]);
}
// Add the "viewport" field
$this->connection->query("ALTER TABLE `tl_layout` ADD `viewport` varchar(255) NOT NULL default ''");
}
// TODO: implement down() and preDown() for going a version back.
?>
from installation-bundle.
Yeah that is possible, I'm just not sure if it's supposed to be for that. There's also Doctrine Fixtures thought that might be the right thing for website templates.
from installation-bundle.
For templates (in other words: dummy data) you are right, fixtures are the way to go.
However, the migrations are exactly for upgrading (and downgrading) a database in terms of versioning.
from installation-bundle.
Related Issues (20)
- Check for disabled symlink function HOT 4
- Install tool cache warm up in dev environment HOT 2
- Hook "sqlCompileCommands" not called HOT 3
- Install Tool does not work in dev environment HOT 4
- app/console doctrine:cache:clear contao.cache is not working HOT 17
- The MySQL version check cannot determine the current version HOT 11
- DB update loads schema of none Contao tables HOT 13
- Check all innodb_large_prefix requirements HOT 5
- 4.4.11: Install-Tool: Call to a member function getKernel() on null HOT 23
- install tool fails in dev environment if user table does not exist HOT 4
- Schema diff fails with MariaDB 10.2 HOT 5
- Calling install tool throws error after update to Contao 4.5.1 HOT 2
- exception due to notice in PHP date function HOT 1
- Installation with MariaDB>10.3.1 not possible HOT 10
- Installation without innodb_large_prefix fails HOT 3
- Installation with innodb_file_format = Antelope and innodb_large_prefix = On fails HOT 5
- Installation tool does not correctly encode cols named 'row' HOT 22
- admin is a reserved word in mySQL 8 HOT 4
- Supply alternative for runonce.php HOT 2
- handle mod_article_teaser and mod_article_plain selection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from installation-bundle.