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.129.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.16.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.128.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.15.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.14.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.13.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.127.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.12.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.126.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.11.1 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.125.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.11.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.124.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.10.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.123.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.9.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
avm-tools-0.122.0 sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.8.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.7.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
eac_tools-0.6.0 sub/avm-tools/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb