activerecord-clean-db-structure 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 412a73ec5fd32ea8373d0fdc86dfd290f4a8524d1e7f3fbf3611fd5c4f75fefa
4
- data.tar.gz: b5020420e5d3b258e252306411f09cdb82e2c57dfc41dcd81775b0e866f28470
3
+ metadata.gz: '08c48e1dbdf0558fcbcb0f93982dafd1ac7d58063fa445cc10dd0473dc6a9d27'
4
+ data.tar.gz: bcc6aa3df97244977fad69c275f1ee815ceb706fd5674f2832644f4f119e44c0
5
5
  SHA512:
6
- metadata.gz: e9f21da42eecc194ae9dbbfc5289d2733d115e7ddfe9a7bdea651bc8171cc15514af85e5825386f8bba14d73d3b58136433b92c9fcc94ed8a35d8dfae306cc5e
7
- data.tar.gz: 16988f199aff2f875dc0513e18da004d2b6ed4d09fbda5d0de05e914f69ae69ca6c685a408c6393a5467a5e957eac4b13da4f207283650b08fb786f4c4a3a535
6
+ metadata.gz: 21277622911894dd05ab07bdf320bc59b467e9c29c9aa5d24f22b0e463e24af7d3804d15b4eb66647eea98be94400f45ec519a55776211a14ff9ea95c6fb9ba2
7
+ data.tar.gz: 515d4fae0ddb8588e8426e8a5a932a6c8c116586f53bcc7c2020f3ae6b45444f57a4a9aebefd3957ba55f2e011ca0c54dc7c0321f8ce3f4467f8f0db9f8dd034
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on:
3
+ pull_request:
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby: ["3.1", "3.2"]
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: ${{ matrix.ruby }}
15
+ bundler-cache: true
16
+ - run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
 
5
5
  * ...
6
6
 
7
+ ## 0.4.3 2024-09-22
8
+
9
+ * Fix additional regexp warnings from "rake test". [#50](https://github.com/lfittl/activerecord-clean-db-structure/pull/50)
10
+
11
+ ## 0.4.2 2024-09-22
12
+
13
+ * Add an option to not remove extensions [#43](https://github.com/lfittl/activerecord-clean-db-structure/pull/43)
14
+ * Fix incorrect primary structure.sql filename in the case of multi-database setup [#44](https://github.com/lfittl/activerecord-clean-db-structure/pull/44)
15
+ * Fix regexp warnings [#49](https://github.com/lfittl/activerecord-clean-db-structure/pull/49)
16
+
7
17
  ## 0.4.1 2024-08-28
8
18
 
9
19
  * Fix Rake task name for 6.1+ [#32](https://github.com/lfittl/activerecord-clean-db-structure/pull/32)
data/Gemfile.lock CHANGED
@@ -1,31 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-clean-db-structure (0.4.1)
4
+ activerecord-clean-db-structure (0.4.3)
5
5
  activerecord (>= 4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.4.3)
11
- activesupport (= 7.0.4.3)
12
- activerecord (7.0.4.3)
13
- activemodel (= 7.0.4.3)
14
- activesupport (= 7.0.4.3)
15
- activesupport (7.0.4.3)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
10
+ activemodel (7.2.1)
11
+ activesupport (= 7.2.1)
12
+ activerecord (7.2.1)
13
+ activemodel (= 7.2.1)
14
+ activesupport (= 7.2.1)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.2.1)
17
+ base64
18
+ bigdecimal
19
+ concurrent-ruby (~> 1.0, >= 1.3.1)
20
+ connection_pool (>= 2.2.5)
21
+ drb
17
22
  i18n (>= 1.6, < 2)
23
+ logger (>= 1.4.2)
18
24
  minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- concurrent-ruby (1.3.3)
25
+ securerandom (>= 0.3)
26
+ tzinfo (~> 2.0, >= 2.0.5)
27
+ base64 (0.2.0)
28
+ bigdecimal (3.1.8)
29
+ concurrent-ruby (1.3.4)
30
+ connection_pool (2.4.1)
31
+ drb (2.2.1)
21
32
  i18n (1.14.5)
22
33
  concurrent-ruby (~> 1.0)
23
- minitest (5.24.1)
24
- rake (13.0.6)
34
+ logger (1.6.1)
35
+ minitest (5.25.1)
36
+ rake (13.2.1)
37
+ securerandom (0.3.1)
38
+ timeout (0.4.1)
25
39
  tzinfo (2.0.6)
26
40
  concurrent-ruby (~> 1.0)
27
41
 
28
42
  PLATFORMS
43
+ arm64-darwin-22
29
44
  ruby
30
45
 
31
46
  DEPENDENCIES
@@ -33,4 +48,4 @@ DEPENDENCIES
33
48
  rake (~> 13)
34
49
 
35
50
  BUNDLED WITH
36
- 1.17.3
51
+ 2.5.18
data/README.md CHANGED
@@ -87,6 +87,17 @@ INSERT INTO "schema_migrations" (version) VALUES
87
87
  ;
88
88
  ```
89
89
 
90
+ By default the gem will remove [some extensions](https://github.com/ghiculescu/activerecord-clean-db-structure/blob/c9551391476a5e7a08ff314501af89baddcf669a/lib/activerecord-clean-db-structure/clean_dump.rb#L24) that typically aren't needed in structure dumps. You can choose to keep all, or just some, of those extensions:
91
+
92
+ ```ruby
93
+ Rails.application.configure do
94
+ config.activerecord_clean_db_structure.keep_extensions = :all
95
+
96
+ # This does the same thing as :all. You can choose which optional extensions to keep.
97
+ config.activerecord_clean_db_structure.keep_extensions = ["pg_stat_statements", "pg_buffercache"]
98
+ end
99
+ ```
100
+
90
101
  ## Authors
91
102
 
92
103
  * [Lukas Fittl](https://github.com/lfittl)
data/Rakefile CHANGED
@@ -1,3 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'bundler/gem_tasks'
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: %i[test]
@@ -21,19 +21,22 @@ module ActiveRecordCleanDbStructure
21
21
  dump.gsub!(/^SET xmloption = content;\n/m, '') # 12
22
22
  dump.gsub!(/^SET default_table_access_method = heap;\n/m, '') # 12
23
23
 
24
- # Remove pg_stat_statements extension (its not relevant to the code)
25
- dump.gsub!(/^CREATE EXTENSION IF NOT EXISTS pg_stat_statements.*/, '')
26
- dump.gsub!(/^-- Name: (EXTENSION )?pg_stat_statements;.*/, '')
27
-
28
- # Remove pg_buffercache extension (its not relevant to the code)
29
- dump.gsub!(/^CREATE EXTENSION IF NOT EXISTS pg_buffercache.*/, '')
30
- dump.gsub!(/^-- Name: (EXTENSION )?pg_buffercache;.*/, '')
24
+ extensions_to_remove = ["pg_stat_statements", "pg_buffercache"]
25
+ if options[:keep_extensions] == :all
26
+ extensions_to_remove = []
27
+ elsif options[:keep_extensions]
28
+ extensions_to_remove -= Array(options[:keep_extensions])
29
+ end
30
+ extensions_to_remove.each do |ext|
31
+ dump.gsub!(/^CREATE EXTENSION IF NOT EXISTS #{ext}.*/, '')
32
+ dump.gsub!(/^-- Name: (EXTENSION )?#{ext};.*/, '')
33
+ end
31
34
 
32
35
  # Remove comments on extensions, they create problems if the extension is owned by another user
33
36
  dump.gsub!(/^COMMENT ON EXTENSION .*/, '')
34
37
 
35
38
  # Remove useless, version-specific parts of comments
36
- dump.gsub!(/^-- (.*); Schema: ([\w_\.]+|-); Owner: -.*/, '-- \1')
39
+ dump.gsub!(/^-- (.*); Schema: ([\w\.]+|-); Owner: -.*/, '-- \1')
37
40
 
38
41
  # Remove useless comment lines
39
42
  dump.gsub!(/^--$/, '')
@@ -44,8 +47,8 @@ module ActiveRecordCleanDbStructure
44
47
  # This is a bit optimistic, but works as long as you don't have an id field thats not a sequence/uuid
45
48
  dump.gsub!(/^ id integer NOT NULL(,)?$/, ' id SERIAL PRIMARY KEY\1')
46
49
  dump.gsub!(/^ id bigint NOT NULL(,)?$/, ' id BIGSERIAL PRIMARY KEY\1')
47
- dump.gsub!(/^ id uuid DEFAULT ([\w_]+\.)?uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1uuid_generate_v4() PRIMARY KEY\2')
48
- dump.gsub!(/^ id uuid DEFAULT ([\w_]+\.)?gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1gen_random_uuid() PRIMARY KEY\2')
50
+ dump.gsub!(/^ id uuid DEFAULT ([\w]+\.)?uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1uuid_generate_v4() PRIMARY KEY\2')
51
+ dump.gsub!(/^ id uuid DEFAULT ([\w]+\.)?gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1gen_random_uuid() PRIMARY KEY\2')
49
52
  dump.gsub!(/^CREATE SEQUENCE [\w\.]+_id_seq\s+(AS integer\s+)?START WITH 1\s+INCREMENT BY 1\s+NO MINVALUE\s+NO MAXVALUE\s+CACHE 1;$/, '')
50
53
  dump.gsub!(/^ALTER SEQUENCE [\w\.]+_id_seq OWNED BY .*;$/, '')
51
54
  dump.gsub!(/^ALTER TABLE ONLY [\w\.]+ ALTER COLUMN id SET DEFAULT nextval\('[\w\.]+_id_seq'::regclass\);$/, '')
@@ -56,7 +59,7 @@ module ActiveRecordCleanDbStructure
56
59
  end
57
60
 
58
61
  # Remove inherited tables
59
- inherited_tables_regexp = /-- Name: ([\w_\.]+); Type: TABLE\n\n[^;]+?INHERITS \([\w_\.]+\);/m
62
+ inherited_tables_regexp = /-- Name: ([\w\.]+); Type: TABLE\n\n[^;]+?INHERITS \([\w\.]+\);/m
60
63
  inherited_tables = dump.scan(inherited_tables_regexp).map(&:first)
61
64
  dump.gsub!(inherited_tables_regexp, '')
62
65
  inherited_tables.each do |inherited_table|
@@ -73,15 +76,15 @@ module ActiveRecordCleanDbStructure
73
76
  partitioned_tables = []
74
77
 
75
78
  # Postgres 12 pg_dump will output separate ATTACH PARTITION statements (even when run against an 11 or older server)
76
- partitioned_tables_regexp1 = /ALTER TABLE ONLY [\w_\.]+ ATTACH PARTITION ([\w_\.]+)/
79
+ partitioned_tables_regexp1 = /ALTER TABLE ONLY [\w\.]+ ATTACH PARTITION ([\w\.]+)/
77
80
  partitioned_tables += dump.scan(partitioned_tables_regexp1).map(&:last)
78
81
 
79
82
  # Earlier versions use an inline PARTITION OF
80
- partitioned_tables_regexp2 = /-- Name: ([\w_\.]+); Type: TABLE\n\n[^;]+?PARTITION OF [\w_\.]+\n[^;]+?;/m
83
+ partitioned_tables_regexp2 = /-- Name: ([\w\.]+); Type: TABLE\n\n[^;]+?PARTITION OF [\w\.]+\n[^;]+?;/m
81
84
  partitioned_tables += dump.scan(partitioned_tables_regexp2).map(&:first)
82
85
 
83
86
  partitioned_tables.each do |partitioned_table|
84
- partitioned_schema_name, partitioned_table_name_only = partitioned_table.split('.', 2)
87
+ _partitioned_schema_name, partitioned_table_name_only = partitioned_table.split('.', 2)
85
88
  dump.gsub!(/-- Name: #{partitioned_table_name_only}; Type: TABLE/, '')
86
89
  dump.gsub!(/CREATE TABLE #{partitioned_table} \([^;]+;/m, '')
87
90
  dump.gsub!(/ALTER TABLE ONLY ([\w_\.]+) ATTACH PARTITION #{partitioned_table}[^;]+;/m, '')
@@ -101,7 +104,7 @@ module ActiveRecordCleanDbStructure
101
104
  dump.gsub!(/-- Name: #{partitioned_table}_pkey; Type: INDEX ATTACH\n\n[^;]+?ATTACH PARTITION ([\w_]+\.)?#{partitioned_table}_pkey;/, '')
102
105
  end
103
106
  # This is mostly done to allow restoring Postgres 11 output on Postgres 10
104
- dump.gsub!(/CREATE INDEX ([\w_]+) ON ONLY/, 'CREATE INDEX \\1 ON')
107
+ dump.gsub!(/CREATE INDEX ([\w]+) ON ONLY/, 'CREATE INDEX \\1 ON')
105
108
 
106
109
  if options[:order_schema_migrations_values] == true
107
110
  schema_migrations_cleanup
@@ -121,7 +124,7 @@ module ActiveRecordCleanDbStructure
121
124
  dump.gsub!(/^CREATE( UNIQUE)? INDEX \w+ ON .+\n+/, '')
122
125
  dump.gsub!(/^-- Name: \w+; Type: INDEX\n+/, '')
123
126
  indexes.each do |table, indexes_for_table|
124
- dump.gsub!(/^(CREATE TABLE #{table}\b(:?[^;\n]*\n)+\);\n)/) { $1 + "\n" + indexes_for_table }
127
+ dump.gsub!(/^(CREATE TABLE #{table}\b(:?[^;\n]*\n)+\);*\n(?:.*);*)/) { $1 + "\n\n" + indexes_for_table }
125
128
  end
126
129
  end
127
130
 
@@ -148,7 +151,7 @@ module ActiveRecordCleanDbStructure
148
151
  inside_table = true
149
152
  columns = []
150
153
  result << source_line
151
- elsif source_line.start_with?(");")
154
+ elsif source_line.start_with?(")")
152
155
  if inside_table
153
156
  inside_table = false
154
157
  columns.sort_by!(&:first)
@@ -9,7 +9,8 @@ Rake::Task[ActiveRecord.version >= Gem::Version.new('6.1') ? 'db:schema:dump' :
9
9
  databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
10
10
  ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |spec_name|
11
11
  Rails.application.config.paths['db'].each do |path|
12
- filenames << File.join(path, spec_name + '_structure.sql')
12
+ filename = spec_name == 'primary' ? 'structure.sql' : spec_name + '_structure.sql'
13
+ filenames << File.join(path, filename)
13
14
  end
14
15
  end
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordCleanDbStructure
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.3'
3
3
  end
@@ -0,0 +1,35 @@
1
+ require "test_helper"
2
+
3
+ class CleanDumpTest < Minitest::Test
4
+ def test_basic_case
5
+ assert_cleans_dump "expectations/default_props.sql", {}
6
+ end
7
+
8
+ def test_ignore_ids
9
+ assert_cleans_dump "expectations/ignore_ids.sql", { ignore_ids: true }
10
+ end
11
+
12
+ def test_order_column_definitions
13
+ assert_cleans_dump "expectations/order_column_definitions.sql", { order_column_definitions: true }
14
+ end
15
+
16
+ def test_order_schema_migrations_values
17
+ assert_cleans_dump "expectations/order_schema_migrations_values.sql", { order_schema_migrations_values: true }
18
+ end
19
+
20
+ def test_indexes_after_tables
21
+ assert_cleans_dump "expectations/indexes_after_tables.sql", { indexes_after_tables: true }
22
+ end
23
+
24
+ def test_keep_extensions_all
25
+ assert_cleans_dump "expectations/keep_extensions_all.sql", { keep_extensions: :all }
26
+ end
27
+
28
+ private
29
+
30
+ def assert_cleans_dump(expected_output_path, props)
31
+ cleaner = ActiveRecordCleanDbStructure::CleanDump.new(File.read(File.join(__dir__, "data/input.sql")), props)
32
+ cleaner.run
33
+ assert_equal File.read(File.join(__dir__, expected_output_path)), cleaner.dump
34
+ end
35
+ end
@@ -0,0 +1,162 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET idle_in_transaction_session_timeout = 0;
4
+ SET client_encoding = 'UTF8';
5
+ SET standard_conforming_strings = on;
6
+ SELECT pg_catalog.set_config('search_path', '', false);
7
+ SET check_function_bodies = false;
8
+ SET xmloption = content;
9
+ SET client_min_messages = warning;
10
+ SET row_security = off;
11
+
12
+ --
13
+ -- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
14
+ --
15
+
16
+ CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
17
+
18
+
19
+ --
20
+ -- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -
21
+ --
22
+
23
+ COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
24
+
25
+
26
+ SET default_tablespace = '';
27
+
28
+ SET default_table_access_method = heap;
29
+
30
+ --
31
+ -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
32
+ --
33
+
34
+ CREATE TABLE public.ar_internal_metadata (
35
+ key character varying NOT NULL,
36
+ value character varying,
37
+ created_at timestamp(6) without time zone NOT NULL,
38
+ updated_at timestamp(6) without time zone NOT NULL
39
+ );
40
+
41
+
42
+ --
43
+ -- Name: delayed_jobs; Type: TABLE; Schema: public; Owner: -
44
+ --
45
+
46
+ CREATE TABLE public.delayed_jobs (
47
+ id bigint NOT NULL,
48
+ priority integer DEFAULT 0,
49
+ attempts integer DEFAULT 0,
50
+ handler text,
51
+ last_error text,
52
+ run_at timestamp without time zone,
53
+ locked_at timestamp without time zone,
54
+ failed_at timestamp without time zone,
55
+ locked_by character varying(255),
56
+ queue character varying(255),
57
+ created_at timestamp without time zone NOT NULL,
58
+ updated_at timestamp without time zone NOT NULL,
59
+ metadata jsonb DEFAULT '{}'::jsonb,
60
+ whodunnit text
61
+ )
62
+ WITH (fillfactor='85');
63
+
64
+
65
+ --
66
+ -- Name: delayed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
67
+ --
68
+
69
+ CREATE SEQUENCE public.delayed_jobs_id_seq
70
+ START WITH 1
71
+ INCREMENT BY 1
72
+ NO MINVALUE
73
+ NO MAXVALUE
74
+ CACHE 1;
75
+
76
+
77
+ --
78
+ -- Name: delayed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
79
+ --
80
+
81
+ ALTER SEQUENCE public.delayed_jobs_id_seq OWNED BY public.delayed_jobs.id;
82
+
83
+
84
+ --
85
+ -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
86
+ --
87
+
88
+ CREATE TABLE public.schema_migrations (
89
+ version character varying NOT NULL
90
+ );
91
+
92
+
93
+ --
94
+ -- Name: delayed_jobs id; Type: DEFAULT; Schema: public; Owner: -
95
+ --
96
+
97
+ ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public.delayed_jobs_id_seq'::regclass);
98
+
99
+
100
+ --
101
+ -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
102
+ --
103
+
104
+ ALTER TABLE ONLY public.ar_internal_metadata
105
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
106
+
107
+
108
+ --
109
+ -- Name: delayed_jobs delayed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
110
+ --
111
+
112
+ ALTER TABLE ONLY public.delayed_jobs
113
+ ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
114
+
115
+
116
+ --
117
+ -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
118
+ --
119
+
120
+ ALTER TABLE ONLY public.schema_migrations
121
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
122
+
123
+
124
+ --
125
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX; Schema: public; Owner: -
126
+ --
127
+
128
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
129
+
130
+
131
+ --
132
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX; Schema: public; Owner: -
133
+ --
134
+
135
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
136
+
137
+
138
+ --
139
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX; Schema: public; Owner: -
140
+ --
141
+
142
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
143
+
144
+
145
+ --
146
+ -- PostgreSQL database dump complete
147
+ --
148
+
149
+ SET search_path TO "$user", public;
150
+
151
+ INSERT INTO "schema_migrations" (version) VALUES
152
+ ('20240822225012'),
153
+ ('20240822224954'),
154
+ ('20240725043656'),
155
+ ('20240621041110'),
156
+ ('20240621020038'),
157
+ ('20220802204003'),
158
+ ('20211125055031'),
159
+ ('20211012054749'),
160
+ ('20210923052631'),
161
+ ('20210903003251');
162
+
@@ -0,0 +1,78 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ SET default_tablespace = '';
10
+
11
+ -- Name: ar_internal_metadata; Type: TABLE
12
+
13
+ CREATE TABLE public.ar_internal_metadata (
14
+ key character varying NOT NULL,
15
+ value character varying,
16
+ created_at timestamp(6) without time zone NOT NULL,
17
+ updated_at timestamp(6) without time zone NOT NULL
18
+ );
19
+
20
+ -- Name: delayed_jobs; Type: TABLE
21
+
22
+ CREATE TABLE public.delayed_jobs (
23
+ id BIGSERIAL PRIMARY KEY,
24
+ priority integer DEFAULT 0,
25
+ attempts integer DEFAULT 0,
26
+ handler text,
27
+ last_error text,
28
+ run_at timestamp without time zone,
29
+ locked_at timestamp without time zone,
30
+ failed_at timestamp without time zone,
31
+ locked_by character varying(255),
32
+ queue character varying(255),
33
+ created_at timestamp without time zone NOT NULL,
34
+ updated_at timestamp without time zone NOT NULL,
35
+ metadata jsonb DEFAULT '{}'::jsonb,
36
+ whodunnit text
37
+ )
38
+ WITH (fillfactor='85');
39
+
40
+ -- Name: schema_migrations; Type: TABLE
41
+
42
+ CREATE TABLE public.schema_migrations (
43
+ version character varying NOT NULL
44
+ );
45
+
46
+ ALTER TABLE ONLY public.ar_internal_metadata
47
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
48
+
49
+ ALTER TABLE ONLY public.schema_migrations
50
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
51
+
52
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX
53
+
54
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
55
+
56
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX
57
+
58
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
59
+
60
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX
61
+
62
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
63
+
64
+ -- PostgreSQL database dump complete
65
+
66
+ SET search_path TO "$user", public;
67
+
68
+ INSERT INTO "schema_migrations" (version) VALUES
69
+ ('20240822225012'),
70
+ ('20240822224954'),
71
+ ('20240725043656'),
72
+ ('20240621041110'),
73
+ ('20240621020038'),
74
+ ('20220802204003'),
75
+ ('20211125055031'),
76
+ ('20211012054749'),
77
+ ('20210923052631'),
78
+ ('20210903003251');
@@ -0,0 +1,104 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ SET default_tablespace = '';
10
+
11
+ -- Name: ar_internal_metadata; Type: TABLE
12
+
13
+ CREATE TABLE public.ar_internal_metadata (
14
+ key character varying NOT NULL,
15
+ value character varying,
16
+ created_at timestamp(6) without time zone NOT NULL,
17
+ updated_at timestamp(6) without time zone NOT NULL
18
+ );
19
+
20
+ -- Name: delayed_jobs; Type: TABLE
21
+
22
+ CREATE TABLE public.delayed_jobs (
23
+ id bigint NOT NULL,
24
+ priority integer DEFAULT 0,
25
+ attempts integer DEFAULT 0,
26
+ handler text,
27
+ last_error text,
28
+ run_at timestamp without time zone,
29
+ locked_at timestamp without time zone,
30
+ failed_at timestamp without time zone,
31
+ locked_by character varying(255),
32
+ queue character varying(255),
33
+ created_at timestamp without time zone NOT NULL,
34
+ updated_at timestamp without time zone NOT NULL,
35
+ metadata jsonb DEFAULT '{}'::jsonb,
36
+ whodunnit text
37
+ )
38
+ WITH (fillfactor='85');
39
+
40
+ -- Name: delayed_jobs_id_seq; Type: SEQUENCE
41
+
42
+ CREATE SEQUENCE public.delayed_jobs_id_seq
43
+ START WITH 1
44
+ INCREMENT BY 1
45
+ NO MINVALUE
46
+ NO MAXVALUE
47
+ CACHE 1;
48
+
49
+ -- Name: delayed_jobs_id_seq; Type: SEQUENCE OWNED BY
50
+
51
+ ALTER SEQUENCE public.delayed_jobs_id_seq OWNED BY public.delayed_jobs.id;
52
+
53
+ -- Name: schema_migrations; Type: TABLE
54
+
55
+ CREATE TABLE public.schema_migrations (
56
+ version character varying NOT NULL
57
+ );
58
+
59
+ -- Name: delayed_jobs id; Type: DEFAULT
60
+
61
+ ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public.delayed_jobs_id_seq'::regclass);
62
+
63
+ -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT
64
+
65
+ ALTER TABLE ONLY public.ar_internal_metadata
66
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
67
+
68
+ -- Name: delayed_jobs delayed_jobs_pkey; Type: CONSTRAINT
69
+
70
+ ALTER TABLE ONLY public.delayed_jobs
71
+ ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
72
+
73
+ -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT
74
+
75
+ ALTER TABLE ONLY public.schema_migrations
76
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
77
+
78
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX
79
+
80
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
81
+
82
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX
83
+
84
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
85
+
86
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX
87
+
88
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
89
+
90
+ -- PostgreSQL database dump complete
91
+
92
+ SET search_path TO "$user", public;
93
+
94
+ INSERT INTO "schema_migrations" (version) VALUES
95
+ ('20240822225012'),
96
+ ('20240822224954'),
97
+ ('20240725043656'),
98
+ ('20240621041110'),
99
+ ('20240621020038'),
100
+ ('20220802204003'),
101
+ ('20211125055031'),
102
+ ('20211012054749'),
103
+ ('20210923052631'),
104
+ ('20210903003251');
@@ -0,0 +1,70 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ SET default_tablespace = '';
10
+
11
+ -- Name: ar_internal_metadata; Type: TABLE
12
+
13
+ CREATE TABLE public.ar_internal_metadata (
14
+ key character varying NOT NULL,
15
+ value character varying,
16
+ created_at timestamp(6) without time zone NOT NULL,
17
+ updated_at timestamp(6) without time zone NOT NULL
18
+ );
19
+
20
+ -- Name: delayed_jobs; Type: TABLE
21
+
22
+ CREATE TABLE public.delayed_jobs (
23
+ id BIGSERIAL PRIMARY KEY,
24
+ priority integer DEFAULT 0,
25
+ attempts integer DEFAULT 0,
26
+ handler text,
27
+ last_error text,
28
+ run_at timestamp without time zone,
29
+ locked_at timestamp without time zone,
30
+ failed_at timestamp without time zone,
31
+ locked_by character varying(255),
32
+ queue character varying(255),
33
+ created_at timestamp without time zone NOT NULL,
34
+ updated_at timestamp without time zone NOT NULL,
35
+ metadata jsonb DEFAULT '{}'::jsonb,
36
+ whodunnit text
37
+ )
38
+ WITH (fillfactor='85');
39
+
40
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
41
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
42
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
43
+
44
+ -- Name: schema_migrations; Type: TABLE
45
+
46
+ CREATE TABLE public.schema_migrations (
47
+ version character varying NOT NULL
48
+ );
49
+
50
+ ALTER TABLE ONLY public.ar_internal_metadata
51
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
52
+
53
+ ALTER TABLE ONLY public.schema_migrations
54
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
55
+
56
+ -- PostgreSQL database dump complete
57
+
58
+ SET search_path TO "$user", public;
59
+
60
+ INSERT INTO "schema_migrations" (version) VALUES
61
+ ('20240822225012'),
62
+ ('20240822224954'),
63
+ ('20240725043656'),
64
+ ('20240621041110'),
65
+ ('20240621020038'),
66
+ ('20220802204003'),
67
+ ('20211125055031'),
68
+ ('20211012054749'),
69
+ ('20210923052631'),
70
+ ('20210903003251');
@@ -0,0 +1,84 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ -- Name: pg_stat_statements; Type: EXTENSION
10
+
11
+ CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
12
+
13
+ -- Name: EXTENSION pg_stat_statements; Type: COMMENT
14
+
15
+ SET default_tablespace = '';
16
+
17
+ -- Name: ar_internal_metadata; Type: TABLE
18
+
19
+ CREATE TABLE public.ar_internal_metadata (
20
+ key character varying NOT NULL,
21
+ value character varying,
22
+ created_at timestamp(6) without time zone NOT NULL,
23
+ updated_at timestamp(6) without time zone NOT NULL
24
+ );
25
+
26
+ -- Name: delayed_jobs; Type: TABLE
27
+
28
+ CREATE TABLE public.delayed_jobs (
29
+ id BIGSERIAL PRIMARY KEY,
30
+ priority integer DEFAULT 0,
31
+ attempts integer DEFAULT 0,
32
+ handler text,
33
+ last_error text,
34
+ run_at timestamp without time zone,
35
+ locked_at timestamp without time zone,
36
+ failed_at timestamp without time zone,
37
+ locked_by character varying(255),
38
+ queue character varying(255),
39
+ created_at timestamp without time zone NOT NULL,
40
+ updated_at timestamp without time zone NOT NULL,
41
+ metadata jsonb DEFAULT '{}'::jsonb,
42
+ whodunnit text
43
+ )
44
+ WITH (fillfactor='85');
45
+
46
+ -- Name: schema_migrations; Type: TABLE
47
+
48
+ CREATE TABLE public.schema_migrations (
49
+ version character varying NOT NULL
50
+ );
51
+
52
+ ALTER TABLE ONLY public.ar_internal_metadata
53
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
54
+
55
+ ALTER TABLE ONLY public.schema_migrations
56
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
57
+
58
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX
59
+
60
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
61
+
62
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX
63
+
64
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
65
+
66
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX
67
+
68
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
69
+
70
+ -- PostgreSQL database dump complete
71
+
72
+ SET search_path TO "$user", public;
73
+
74
+ INSERT INTO "schema_migrations" (version) VALUES
75
+ ('20240822225012'),
76
+ ('20240822224954'),
77
+ ('20240725043656'),
78
+ ('20240621041110'),
79
+ ('20240621020038'),
80
+ ('20220802204003'),
81
+ ('20211125055031'),
82
+ ('20211012054749'),
83
+ ('20210923052631'),
84
+ ('20210903003251');
@@ -0,0 +1,78 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ SET default_tablespace = '';
10
+
11
+ -- Name: ar_internal_metadata; Type: TABLE
12
+
13
+ CREATE TABLE public.ar_internal_metadata (
14
+ created_at timestamp(6) without time zone NOT NULL,
15
+ key character varying NOT NULL,
16
+ updated_at timestamp(6) without time zone NOT NULL,
17
+ value character varying
18
+ );
19
+
20
+ -- Name: delayed_jobs; Type: TABLE
21
+
22
+ CREATE TABLE public.delayed_jobs (
23
+ attempts integer DEFAULT 0,
24
+ created_at timestamp without time zone NOT NULL,
25
+ failed_at timestamp without time zone,
26
+ handler text,
27
+ id BIGSERIAL PRIMARY KEY,
28
+ last_error text,
29
+ locked_at timestamp without time zone,
30
+ locked_by character varying(255),
31
+ metadata jsonb DEFAULT '{}'::jsonb,
32
+ priority integer DEFAULT 0,
33
+ queue character varying(255),
34
+ run_at timestamp without time zone,
35
+ updated_at timestamp without time zone NOT NULL,
36
+ whodunnit text
37
+ )
38
+ WITH (fillfactor='85');
39
+
40
+ -- Name: schema_migrations; Type: TABLE
41
+
42
+ CREATE TABLE public.schema_migrations (
43
+ version character varying NOT NULL
44
+ );
45
+
46
+ ALTER TABLE ONLY public.ar_internal_metadata
47
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
48
+
49
+ ALTER TABLE ONLY public.schema_migrations
50
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
51
+
52
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX
53
+
54
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
55
+
56
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX
57
+
58
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
59
+
60
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX
61
+
62
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
63
+
64
+ -- PostgreSQL database dump complete
65
+
66
+ SET search_path TO "$user", public;
67
+
68
+ INSERT INTO "schema_migrations" (version) VALUES
69
+ ('20240822225012'),
70
+ ('20240822224954'),
71
+ ('20240725043656'),
72
+ ('20240621041110'),
73
+ ('20240621020038'),
74
+ ('20220802204003'),
75
+ ('20211125055031'),
76
+ ('20211012054749'),
77
+ ('20210923052631'),
78
+ ('20210903003251');
@@ -0,0 +1,80 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET client_encoding = 'UTF8';
4
+ SET standard_conforming_strings = on;
5
+ SELECT pg_catalog.set_config('search_path', '', false);
6
+ SET check_function_bodies = false;
7
+ SET client_min_messages = warning;
8
+
9
+ SET default_tablespace = '';
10
+
11
+ -- Name: ar_internal_metadata; Type: TABLE
12
+
13
+ CREATE TABLE public.ar_internal_metadata (
14
+ key character varying NOT NULL,
15
+ value character varying,
16
+ created_at timestamp(6) without time zone NOT NULL,
17
+ updated_at timestamp(6) without time zone NOT NULL
18
+ );
19
+
20
+ -- Name: delayed_jobs; Type: TABLE
21
+
22
+ CREATE TABLE public.delayed_jobs (
23
+ id BIGSERIAL PRIMARY KEY,
24
+ priority integer DEFAULT 0,
25
+ attempts integer DEFAULT 0,
26
+ handler text,
27
+ last_error text,
28
+ run_at timestamp without time zone,
29
+ locked_at timestamp without time zone,
30
+ failed_at timestamp without time zone,
31
+ locked_by character varying(255),
32
+ queue character varying(255),
33
+ created_at timestamp without time zone NOT NULL,
34
+ updated_at timestamp without time zone NOT NULL,
35
+ metadata jsonb DEFAULT '{}'::jsonb,
36
+ whodunnit text
37
+ )
38
+ WITH (fillfactor='85');
39
+
40
+ -- Name: schema_migrations; Type: TABLE
41
+
42
+ CREATE TABLE public.schema_migrations (
43
+ version character varying NOT NULL
44
+ );
45
+
46
+ ALTER TABLE ONLY public.ar_internal_metadata
47
+ ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
48
+
49
+ ALTER TABLE ONLY public.schema_migrations
50
+ ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
51
+
52
+ -- Name: index_delayed_jobs_on_locked_by; Type: INDEX
53
+
54
+ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by);
55
+
56
+ -- Name: index_delayed_jobs_on_queue; Type: INDEX
57
+
58
+ CREATE INDEX index_delayed_jobs_on_queue ON public.delayed_jobs USING btree (queue);
59
+
60
+ -- Name: index_delayed_jobs_on_run_at; Type: INDEX
61
+
62
+ CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
63
+
64
+ -- PostgreSQL database dump complete
65
+
66
+ SET search_path TO "$user", public;
67
+
68
+ INSERT INTO "schema_migrations" (version) VALUES
69
+ ('20210903003251')
70
+ ,('20210923052631')
71
+ ,('20211012054749')
72
+ ,('20211125055031')
73
+ ,('20220802204003')
74
+ ,('20240621020038')
75
+ ,('20240621041110')
76
+ ,('20240725043656')
77
+ ,('20240822224954')
78
+ ,('20240822225012')
79
+ ;
80
+
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
+ require "activerecord-clean-db-structure"
3
+ require 'activerecord-clean-db-structure/clean_dump'
4
+
5
+ require "minitest/autorun"
6
+ Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |rb| require(rb) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-clean-db-structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Fittl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
11
+ date: 2024-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,6 +44,7 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - ".github/workflows/ci.yml"
47
48
  - ".gitignore"
48
49
  - CHANGELOG.md
49
50
  - Gemfile
@@ -57,11 +58,20 @@ files:
57
58
  - lib/activerecord-clean-db-structure/railtie.rb
58
59
  - lib/activerecord-clean-db-structure/tasks/clean_db_structure.rake
59
60
  - lib/activerecord-clean-db-structure/version.rb
61
+ - test/clean_dump_test.rb
62
+ - test/data/input.sql
63
+ - test/expectations/default_props.sql
64
+ - test/expectations/ignore_ids.sql
65
+ - test/expectations/indexes_after_tables.sql
66
+ - test/expectations/keep_extensions_all.sql
67
+ - test/expectations/order_column_definitions.sql
68
+ - test/expectations/order_schema_migrations_values.sql
69
+ - test/test_helper.rb
60
70
  homepage: https://github.com/lfittl/activerecord-clean-db-structure
61
71
  licenses:
62
72
  - MIT
63
73
  metadata: {}
64
- post_install_message:
74
+ post_install_message:
65
75
  rdoc_options: []
66
76
  require_paths:
67
77
  - lib
@@ -76,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  requirements: []
79
- rubygems_version: 3.1.6
80
- signing_key:
89
+ rubygems_version: 3.0.3.1
90
+ signing_key:
81
91
  specification_version: 4
82
92
  summary: Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
83
93
  test_files: []