REFACTOR: Restoring of backups and migration of uploads to S3

This commit is contained in:
Gerhard Schlager
2020-01-13 00:12:27 +01:00
parent f10078eab4
commit e474cda321
37 changed files with 2454 additions and 1029 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
class DropPostColumns < ActiveRecord::Migration[5.2]
DROPPED_COLUMNS ||= {
posts: %i{via_email raw_email}
}
def up
remove_column :posts, :via_email
remove_column :posts, :raw_email
raise ActiveRecord::Rollback
end
def down
raise "not tested"
end
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class DropEmailLogsTable < ActiveRecord::Migration[5.2]
DROPPED_TABLES ||= %i{email_logs}
def up
drop_table :email_logs
raise ActiveRecord::Rollback

10
spec/fixtures/db/restore/error.sql vendored Normal file
View File

@@ -0,0 +1,10 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.11 (Debian 10.11-1.pgdg100+1)
-- Dumped by pg_dump version 10.11 (Debian 10.11-1.pgdg100+1)
-- Started on 2019-12-28 00:24:29 UTC
SET foo = 0;

View File

@@ -0,0 +1,31 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.11 (Debian 10.11-1.pgdg100+1)
-- Dumped by pg_dump version 10.11 (Debian 10.11-1.pgdg100+1)
-- Started on 2019-12-28 00:24:29 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 198 (class 1259 OID 16573)
-- Name: foo; Type: TABLE; Schema: public; Owner: -
CREATE TABLE public.foo (
id integer NOT NULL
);

View File

@@ -0,0 +1,49 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.6 (Debian 11.6-1.pgdg90+1)
-- Dumped by pg_dump version 11.6 (Debian 11.6-1.pgdg90+1)
-- Started on 2019-12-28 00:38:51 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 5 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA public;
--
-- TOC entry 4782 (class 0 OID 0)
-- Dependencies: 5
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA public IS 'standard public schema';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 198 (class 1259 OID 16585)
-- Name: foo; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.foo (
id integer NOT NULL
);

View File

@@ -0,0 +1,49 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.1 (Debian 12.1-1.pgdg100+1)
-- Dumped by pg_dump version 12.1 (Debian 12.1-1.pgdg100+1)
-- Started on 2019-12-28 00:35:48 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 5 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA public;
--
-- TOC entry 4825 (class 0 OID 0)
-- Dependencies: 5
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA public IS 'standard public schema';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 204 (class 1259 OID 16587)
-- Name: foo; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.foo (
id integer NOT NULL
);

View File

@@ -0,0 +1,29 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.3.11
-- Dumped by pg_dump version 9.3.11
-- Started on 2019-12-27 20:54:40 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
DROP SCHEMA IF EXISTS restore CASCADE; CREATE SCHEMA restore; SET search_path = restore, public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 274 (class 1259 OID 18691)
-- Name: foo; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE foo (
id integer NOT NULL
);

View File

@@ -0,0 +1,31 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.10
-- Dumped by pg_dump version 9.5.19
-- Started on 2019-12-27 16:08:01 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 285 (class 1259 OID 18706)
-- Name: foo; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.foo (
id integer NOT NULL
);

View File

@@ -0,0 +1,31 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.5
-- Dumped by pg_dump version 9.5.5
-- Started on 2019-11-07 16:41:33 UTC
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 284 (class 1259 OID 18697)
-- Name: foo; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE foo (
id integer NOT NULL
);