First migration. Creates database in copypaste1 format.
This commit is contained in:
parent
04660e191d
commit
442e29adc6
|
@ -15,6 +15,7 @@ class AppKernel extends Kernel
|
|||
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
|
||||
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
||||
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
|
||||
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
||||
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
|
||||
new Skobkin\Bundle\CopyPasteBundle\SkobkinCopyPasteBundle(),
|
||||
);
|
||||
|
|
60
app/DoctrineMigrations/Version20150302205121.php
Normal file
60
app/DoctrineMigrations/Version20150302205121.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* First migration. Creates new database in copypaste1 format or skipping creation if data already exists.
|
||||
*/
|
||||
class Version20150302205121 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$schemaManager = $this->connection->getSchemaManager();
|
||||
|
||||
if ($schemaManager->tablesExist(['lang', 'paste'])) {
|
||||
$this->write('Copypaste1 tables detected. Skiping creation...');
|
||||
} else {
|
||||
$this->write('Creating database in old format...');
|
||||
|
||||
$this->addSql(
|
||||
'CREATE TABLE `lang` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT \'ID\',
|
||||
`name` varchar(100) CHARACTER SET utf8 NOT NULL COMMENT \'Language title for GUI\',
|
||||
`file` varchar(24) CHARACTER SET utf8 NOT NULL COMMENT \'Language filename for GeSHi\',
|
||||
`enabled` tinyint(1) unsigned NOT NULL COMMENT \'Is language usable or not\',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `lang_enabled` (`enabled`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=190 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT=\'Programming languages\''
|
||||
);
|
||||
$this->addSql(
|
||||
'CREATE TABLE `paste` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT \'ID\',
|
||||
`code` mediumtext CHARACTER SET utf8 NOT NULL COMMENT \'Code\',
|
||||
`code_comment` text CHARACTER SET utf8 NOT NULL COMMENT \'Comments for code\',
|
||||
`lang` int(11) unsigned NOT NULL COMMENT \'id языка ввода\',
|
||||
`filename` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT \'Filename\',
|
||||
`name` varchar(48) CHARACTER SET utf8 NOT NULL COMMENT \'Author of quote name\',
|
||||
`date_pub` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT \'Publish date\',
|
||||
`date_exp` timestamp NOT NULL DEFAULT \'0000-00-00 00:00:00\' COMMENT \'Expire date\',
|
||||
`ip` varchar(48) CHARACTER SET utf8 NOT NULL COMMENT \'IP\',
|
||||
`secret` varchar(16) COLLATE utf8_unicode_ci NOT NULL COMMENT \'Paste secret\',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `expiration` (`date_exp`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1194 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE lang');
|
||||
$this->addSql('DROP TABLE paste');
|
||||
}
|
||||
}
|
|
@ -64,6 +64,12 @@ doctrine:
|
|||
auto_generate_proxy_classes: "%kernel.debug%"
|
||||
auto_mapping: true
|
||||
|
||||
doctrine_migrations:
|
||||
dir_name: %kernel.root_dir%/DoctrineMigrations
|
||||
namespace: Application\Migrations
|
||||
table_name: migration_versions
|
||||
name: Application Migrations
|
||||
|
||||
# Swiftmailer Configuration
|
||||
swiftmailer:
|
||||
transport: "%mailer_transport%"
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
"symfony/monolog-bundle": "~2.4",
|
||||
"sensio/distribution-bundle": "~3.0,>=3.0.12",
|
||||
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
|
||||
"incenteev/composer-parameter-handler": "~2.0"
|
||||
"incenteev/composer-parameter-handler": "~2.0",
|
||||
"doctrine/migrations": "1.0.*@dev",
|
||||
"doctrine/doctrine-migrations-bundle": "2.1.*@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"sensio/generator-bundle": "~2.3"
|
||||
|
|
123
composer.lock
generated
123
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "73f15ad91f600008506b4294b7b7d01c",
|
||||
"hash": "5fc11fb887ef6aed953b90118745b7f8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -514,6 +514,65 @@
|
|||
],
|
||||
"time": "2014-11-28 09:43:36"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/doctrine-migrations-bundle",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Doctrine/Bundle/MigrationsBundle",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/DoctrineMigrationsBundle.git",
|
||||
"reference": "6a1bd731dbdd4ad952a3b246a8f38c9c12f52e62"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/6a1bd731dbdd4ad952a3b246a8f38c9c12f52e62",
|
||||
"reference": "6a1bd731dbdd4ad952a3b246a8f38c9c12f52e62",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/doctrine-bundle": "~1.0",
|
||||
"doctrine/migrations": "~1.0@dev",
|
||||
"php": ">=5.3.2",
|
||||
"symfony/framework-bundle": "~2.1"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Bundle\\MigrationsBundle": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Doctrine Project",
|
||||
"homepage": "http://www.doctrine-project.org"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DoctrineMigrationsBundle",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"dbal",
|
||||
"migrations",
|
||||
"schema"
|
||||
],
|
||||
"time": "2015-02-16 13:24:46"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "v1.0.1",
|
||||
|
@ -635,6 +694,64 @@
|
|||
],
|
||||
"time": "2014-09-09 13:34:57"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/migrations",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/migrations.git",
|
||||
"reference": "058a4635ac9b80a5b1997df28a754e64b1425a1d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/migrations/zipball/058a4635ac9b80a5b1997df28a754e64b1425a1d",
|
||||
"reference": "058a4635ac9b80a5b1997df28a754e64b1425a1d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/dbal": "~2.0",
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "2.*",
|
||||
"symfony/yaml": "2.*"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "to run the migration from the console"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\DBAL\\Migrations": "lib"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Database Schema migrations using Doctrine DBAL",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"database",
|
||||
"migrations"
|
||||
],
|
||||
"time": "2015-02-19 08:13:05"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"version": "v2.4.7",
|
||||
|
@ -1667,7 +1784,9 @@
|
|||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"symfony/symfony": 20
|
||||
"symfony/symfony": 20,
|
||||
"doctrine/migrations": 20,
|
||||
"doctrine/doctrine-migrations-bundle": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
|
|
Loading…
Reference in a new issue