Check if variables exists already in the database see #2012

pull/2487/head
jmontoyaa 7 years ago
parent 894aba25f1
commit 7c9d7aedeb
  1. 9
      app/Migrations/Schema/V110/Version20150609113500.php
  2. 9
      app/Migrations/Schema/V110/Version20150616093200.php
  3. 9
      app/Migrations/Schema/V110/Version20150624164100.php
  4. 9
      app/Migrations/Schema/V110/Version20150625155000.php
  5. 24
      app/Migrations/Schema/V111/Version20160610142700.php
  6. 7
      app/Migrations/Schema/V111/Version20160706145000.php

@ -16,9 +16,12 @@ class Version20150609113500 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field
(extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW())");
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'tags'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW())");
}
}
/**

@ -16,9 +16,12 @@ class Version20150616093200 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field (
extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW())");
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'video_url'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW())");
}
}
/**

@ -16,9 +16,12 @@ class Version20150624164100 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field
(extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (3, 16, 'image', 'Image', 1, 1, NOW())");
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'image'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (3, 16, 'image', 'Image', 1, 1, NOW())");
}
}
/**

@ -16,9 +16,12 @@ class Version20150625155000 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field
(extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW())");
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'captcha_blocked_until_date'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW())" );
}
}
/**

@ -21,25 +21,25 @@ class Version20160610142700 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$dataList = $this
->connection
->executeQuery("
SELECT id FROM extra_field
WHERE variable = 'skype' AND extra_field_type = 1
")
->fetchAll();
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($dataList)) {
if (empty($result)) {
$this->addSql("
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (1, 1, 'skype', 'Skype', 1, 1, now())
VALUES (1, 1, 'skype', 'Skype', 1, 1, NOW())
");
}
$this->addSql("
$sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, now())
");
VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, NOW())"
);
}
$this->addSettingCurrent(
'allow_show_skype_account',

@ -21,7 +21,12 @@ class Version20160706145000 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW())");
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'tags'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW())");
}
}
/**

Loading…
Cancel
Save