Ejemplo n.º 1
0
 static function migrate_one($db, $target)
 {
     error_log("Migration vers la version " . $target . ".");
     $class = 'Strass_Migrate_To' . $target;
     if (class_exists($class)) {
         $handler = new $class();
         $handler->run($db);
     } else {
         error_log("Pas de migration vers la version {$target}.");
         die;
     }
     Strass_Version::save($target);
 }
Ejemplo n.º 2
0
 function initDb()
 {
     /* optimisation car la création du schéma peut prendre pas mal de
        temps, et nous somme online */
     $db = Strass_Db::setup($this->dbname, true);
     $dump = $this->sql_dir . '/dump-' . $this->data['site']['association'] . '.sql';
     if (!file_exists($dump)) {
         throw new Exception("Pas de données pour cette association !");
     }
     $sql = file_get_contents($dump);
     $snippets = array_filter(explode(";\n", $sql));
     foreach ($snippets as $snippet) {
         $db->exec($snippet);
     }
     Strass_Version::save(self::VERSION);
     Strass_Migrate::run($db);
 }