function execute()
 {
     $migrations = array();
     foreach ($this->available_migrations as $migration) {
         if (!in_array($migration, $this->schema_migrations)) {
             $migrations[] = $migration;
         }
     }
     sort($migrations);
     foreach ($migrations as $migration) {
         $query = $this->get_migration_contents($migration);
         if ($query === false) {
             throw new Exception("Could not read migration {$migration}.");
         }
         if ($this->run_query($query) === false) {
             throw new Exception("Failed to execute migration {$migration}. " . pg_last_error());
         }
         $schema_migration = new SchemaMigration();
         $schema_migration->version = $migration;
         $schema_migration->save();
     }
 }