Sha256: fa3a03eefc41d4f9ccd926602c61146d1c21152c88d467bdfb2dc084f7db0385

Contents?: true

Size: 900 Bytes

Versions: 49

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

require 'avm/data/instance/unit'

module Avm
  module EacPostgresqlBase0
    class Instance
      class DataUnit < ::Avm::Data::Instance::Unit
        EXTENSION = '.pgdump.gz'

        before_load :clear_database

        def dump_command
          instance.dump_gzip_command
        end

        def load_command
          instance.psql_command.prepend(['gzip', '-d', '@ESC_|'])
        end

        private

        def clear_database
          info 'Clearing database (Dropping all tables)...'
          run_sql(drop_all_tables_sql).if_present { |v| run_sql(v) }
        end

        def drop_all_tables_sql
          "select 'drop table \"' || tablename || '\" cascade;' from pg_tables " \
            "where schemaname = 'public';"
        end

        def run_sql(sql)
          instance.psql_command_command(sql).execute!
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 3 rubygems

Version Path
avm-tools-0.121.2 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.5.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.4.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.3.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.2.2 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.121.1 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.121.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.120.2 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.120.1 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.120.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.119.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.118.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.117.3 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.117.2 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.117.1 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.117.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.116.2 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.116.1 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.116.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-eac_postgresql_base0-0.2.0 lib/avm/eac_postgresql_base0/instance/data_unit.rb