Skip to content

Commit b77ea5a

Browse files
committed
Rename meta_tables_after_main to group_table_definition
1 parent 3391393 commit b77ea5a

File tree

7 files changed

+87
-10
lines changed

7 files changed

+87
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
## 0.5.0 2025-07-09
88

99
### Added
10-
* Introduced `:meta_tables_after_main` option as a more flexible replacement for `:indexes_after_tables`.
10+
* Introduced `:group_table_definition` option as a more flexible replacement for `:indexes_after_tables`.
1111
This option places indexes and deferrable constraints after their respective `CREATE TABLE` statements.
1212

1313
### Deprecated
1414
* `:indexes_after_tables` is now deprecated and will be removed in version 1.0.0.
15-
Please migrate to the new `:meta_tables_after_main` option.
15+
Please migrate to the new `:group_table_definition` option.
1616

1717
## 0.4.3 2024-09-22
1818

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
activerecord-clean-db-structure (0.5.0)
4+
activerecord-clean-db-structure (0.4.3)
55
activerecord (>= 4.2)
66

77
GEM

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ end
4040

4141
## Other options
4242

43-
### meta_tables_after_main
43+
### group_table_definition
4444

45-
You can optionally place indexes and constraints (limited to deferrable ones) after the main tables by setting meta_tables_after_main:
45+
You can optionally place indexes and constraints (limited to deferrable ones) after the main tables by setting group_table_definition:
4646

4747
```ruby
4848
Rails.application.configure do
49-
config.activerecord_clean_db_structure.meta_tables_after_main = true
49+
config.activerecord_clean_db_structure.group_table_definition = true
5050
end
5151
```
5252

lib/activerecord-clean-db-structure/clean_dump.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def clean_options
131131

132132
# TODO: Remove support for :indexes_after_tables in version 1.0.0
133133
if options[:indexes_after_tables]
134-
warn "[DEPRECATION] The :indexes_after_tables option is deprecated and will be removed in version 1.0.0. Use :meta_tables_after_main instead."
134+
warn "[DEPRECATION] The :indexes_after_tables option is deprecated and will be removed in version 1.0.0. Use :group_table_definition instead."
135135
end
136136

137-
if options[:indexes_after_tables] || options[:meta_tables_after_main]
137+
if options[:indexes_after_tables] || options[:group_table_definition]
138138
# Extract indexes
139139
indexes =
140140
dump

test/clean_dump_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ def test_order_schema_migrations_values
1717
assert_cleans_dump "data/input.sql", "expectations/order_schema_migrations_values.sql", order_schema_migrations_values: true
1818
end
1919

20-
def test_meta_tables_after_main
21-
assert_cleans_dump "data/input.sql", "expectations/meta_tables_after_main.sql", meta_tables_after_main: true
20+
def test_indexes_after_tables
21+
assert_cleans_dump "data/input.sql", "expectations/indexes_after_tables.sql", indexes_after_tables: true
22+
end
23+
24+
def test_group_table_definition
25+
assert_cleans_dump "data/input.sql", "expectations/group_table_definition.sql", group_table_definition: true
2226
end
2327

2428
def test_keep_extensions_all
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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_failed_at_IS_NULL" ON public.delayed_jobs USING btree (((failed_at IS NULL)));
43+
CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at) WHERE (locked_at IS NULL);
44+
ALTER TABLE ONLY public.delayed_jobs
45+
ADD CONSTRAINT unique_locked_by_locked_at UNIQUE (locked_by, locked_at) DEFERRABLE INITIALLY DEFERRED;
46+
47+
-- Name: schema_migrations; Type: TABLE
48+
49+
CREATE TABLE public.schema_migrations (
50+
version character varying NOT NULL
51+
);
52+
53+
ALTER TABLE ONLY public.ar_internal_metadata
54+
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
55+
56+
ALTER TABLE ONLY public.schema_migrations
57+
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
58+
59+
-- PostgreSQL database dump complete
60+
61+
SET search_path TO "$user", public;
62+
63+
INSERT INTO "schema_migrations" (version) VALUES
64+
('20240822225012'),
65+
('20240822224954'),
66+
('20240725043656'),
67+
('20240621041110'),
68+
('20240621020038'),
69+
('20220802204003'),
70+
('20211125055031'),
71+
('20211012054749'),
72+
('20210923052631'),
73+
('20210903003251');

0 commit comments

Comments
 (0)