lib/foreman_hooks/host_rename.rb
def initialize_database
      @db = SQLite3::Database.new @database_path
      File.chmod 0600, @database_path
      begin
        @db.execute 'drop table if exists host;'
        @db.execute <<-SQL
            create table host (
              id INT,
              name varchar(254)
            );
        SQL
        sync_host_table
      rescue
        File.unlink @database_path
        raise
      end
    end
def initialize_database
      @db = SQLite3::Database.new @database_path
      File.chmod 0600, @database_path
      begin
        @db.execute 'drop table if exists host;'
        @db.execute <<-SQL
            create table host (
              id INT,
              name varchar(254)
            );
        SQL
        sync_host_table
      rescue
        File.unlink @database_path
        raise
      end
    end
def initialize_database @db = SQLite3 :: Database . new @database_path File . chmod 0600 , @database_path begin @db . execute 'drop table if exists host;' @db . execute <<-SQL SQL sync_host_table rescue File . unlink @database_path raise end end
Initialize an empty database
Initialize an empty database