From 2f50f6e53cc493d94873be4ceb0cc483fade279a Mon Sep 17 00:00:00 2001 From: Andy Atkinson Date: Wed, 7 Feb 2024 16:29:52 -0600 Subject: [PATCH 1/3] Adopt lfittl/activerecord-clean-db-structure This gem reformats the db/structure.sql This could be useful on a team where there are changes to the db/structure.sql file from different team members as they run rails db:migrate on their machines, but those changes aren't intended to be committed. This gem formats the output to minimize any unintended diffs being created, or being committed rails db:migrate was run once here as well which does a one-time reformatting of the file --- Gemfile | 3 + Gemfile.lock | 150 ++++++++------- db/structure.sql | 466 +++++------------------------------------------ erd.pdf | Bin 53922 -> 53922 bytes 4 files changed, 130 insertions(+), 489 deletions(-) diff --git a/Gemfile b/Gemfile index b38bfd1..f541e4f 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,9 @@ gem 'pg_query', '~> 4.2' gem 'pg_search', '~> 2.3' gem 'activerecord-import', '~> 1.5' +# Gem has an unreleased fix https://github.com/lfittl/activerecord-clean-db-structure/pull/36 +gem 'activerecord-clean-db-structure', git: 'git@github.com:lfittl/activerecord-clean-db-structure.git' + # assets gems default Rails 7 app gem 'sprockets-rails', '~> 3.4' gem 'importmap-rails', '~> 1.2' diff --git a/Gemfile.lock b/Gemfile.lock index df2befa..14c7117 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +GIT + remote: git@github.com:lfittl/activerecord-clean-db-structure.git + revision: ed6959ee644787cdf243b77eb61eed3775f394c9 + specs: + activerecord-clean-db-structure (0.4.0) + activerecord (>= 4.2) + GIT remote: https://github.com/andyatkinson/pghero.git revision: 49336df1ca79c3185a1d6b3c0fb87007ef09c7df @@ -16,35 +23,35 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + actioncable (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actionmailbox (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.2) - actionpack (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activesupport (= 7.1.2) + actionmailer (7.1.3) + actionpack (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activesupport (= 7.1.3) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.2) - actionview (= 7.1.2) - activesupport (= 7.1.2) + actionpack (7.1.3) + actionview (= 7.1.3) + activesupport (= 7.1.3) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -52,39 +59,39 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.2) - actionpack (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actiontext (7.1.3) + actionpack (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.2) - activesupport (= 7.1.2) + actionview (7.1.3) + activesupport (= 7.1.3) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) active_record_doctor (1.14.0) activerecord (>= 4.2.0) - activejob (7.1.2) - activesupport (= 7.1.2) + activejob (7.1.3) + activesupport (= 7.1.3) globalid (>= 0.3.6) - activemodel (7.1.2) - activesupport (= 7.1.2) - activerecord (7.1.2) - activemodel (= 7.1.2) - activesupport (= 7.1.2) + activemodel (7.1.3) + activesupport (= 7.1.3) + activerecord (7.1.3) + activemodel (= 7.1.3) + activesupport (= 7.1.3) timeout (>= 0.4.0) activerecord-import (1.5.1) activerecord (>= 4.2) - activestorage (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activesupport (= 7.1.2) + activestorage (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activesupport (= 7.1.3) marcel (~> 1.0) - activesupport (7.1.2) + activesupport (7.1.3) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -99,14 +106,14 @@ GEM benchmark-ips (2.13.0) benchmark-memory (0.2.0) memory_profiler (~> 1) - bigdecimal (3.1.5) + bigdecimal (3.1.6) builder (3.2.4) choice (0.2.0) chronic (0.10.2) code_analyzer (0.5.5) sexp_processor coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) connection_pool (2.4.1) crass (1.0.6) database_consistency (1.7.23) @@ -120,13 +127,12 @@ GEM ruby2_keywords erubi (1.12.0) erubis (2.7.0) - faker (3.2.2) + faker (3.2.3) i18n (>= 1.8.11, < 2) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) + faraday (2.9.0) + faraday-net_http (>= 2.0, < 3.2) + faraday-net_http (3.1.0) + net-http fast_count (0.2.0) activerecord (>= 6.0) fast_jsonapi (1.5) @@ -137,19 +143,19 @@ GEM geocoder (1.8.2) globalid (1.2.1) activesupport (>= 6.1) - google-protobuf (3.25.1-aarch64-linux) - google-protobuf (3.25.1-x86_64-darwin) - google-protobuf (3.25.1-x86_64-linux) + google-protobuf (3.25.2-aarch64-linux) + google-protobuf (3.25.2-x86_64-darwin) + google-protobuf (3.25.2-x86_64-linux) i18n (1.14.1) concurrent-ruby (~> 1.0) importmap-rails (1.2.3) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.7.1) - irb (1.11.0) + io-console (0.7.2) + irb (1.11.1) rdoc - reline (>= 0.3.8) + reline (>= 0.4.2) json (2.7.1) jwt (2.7.1) loofah (2.22.0) @@ -164,8 +170,10 @@ GEM memory_profiler (1.0.1) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.21.2) mutex_m (0.2.0) + net-http (0.4.1) + uri net-imap (0.4.9.1) date net-protocol @@ -197,7 +205,7 @@ GEM puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) - rack (3.0.8) + rack (3.0.9) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -205,20 +213,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.2) - actioncable (= 7.1.2) - actionmailbox (= 7.1.2) - actionmailer (= 7.1.2) - actionpack (= 7.1.2) - actiontext (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activemodel (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + rails (7.1.3) + actioncable (= 7.1.3) + actionmailbox (= 7.1.3) + actionmailer (= 7.1.3) + actionpack (= 7.1.3) + actiontext (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activemodel (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) bundler (>= 1.15.0) - railties (= 7.1.2) + railties (= 7.1.3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -242,9 +250,9 @@ GEM json require_all (~> 3.0) ruby-progressbar - railties (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + railties (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -267,7 +275,7 @@ GEM scenic (1.7.0) activerecord (>= 4.0.0) railties (>= 4.0.0) - sexp_processor (4.17.0) + sexp_processor (4.17.1) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -285,6 +293,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -303,6 +312,7 @@ PLATFORMS DEPENDENCIES active_record_doctor + activerecord-clean-db-structure! activerecord-import (~> 1.5) bcrypt (~> 3.1) benchmark-ips diff --git a/db/structure.sql b/db/structure.sql index 8da33d7..1c04e19 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,13 +1,10 @@ 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; ALTER TABLE IF EXISTS ONLY rideshare.trip_requests DROP CONSTRAINT IF EXISTS fk_rails_fa2679b626; ALTER TABLE IF EXISTS ONLY rideshare.trips DROP CONSTRAINT IF EXISTS fk_rails_e7560abc33; @@ -70,26 +67,19 @@ DROP FUNCTION IF EXISTS rideshare.scrub_email(email_address character varying); DROP FUNCTION IF EXISTS rideshare.fast_count(identifier text, threshold bigint); DROP TYPE IF EXISTS rideshare.vehicle_status; DROP SCHEMA IF EXISTS rideshare; --- --- Name: rideshare; Type: SCHEMA; Schema: -; Owner: - --- -CREATE SCHEMA rideshare; +-- Name: rideshare; Type: SCHEMA +CREATE SCHEMA rideshare; --- --- Name: vehicle_status; Type: TYPE; Schema: rideshare; Owner: - --- +-- Name: vehicle_status; Type: TYPE CREATE TYPE rideshare.vehicle_status AS ENUM ( 'draft', 'published' ); - --- --- Name: fast_count(text, bigint); Type: FUNCTION; Schema: rideshare; Owner: - --- +-- Name: fast_count(text, bigint); Type: FUNCTION CREATE FUNCTION rideshare.fast_count(identifier text, threshold bigint) RETURNS bigint LANGUAGE plpgsql @@ -145,10 +135,7 @@ DECLARE END $$; - --- --- Name: scrub_email(character varying); Type: FUNCTION; Schema: rideshare; Owner: - --- +-- Name: scrub_email(character varying); Type: FUNCTION CREATE FUNCTION rideshare.scrub_email(email_address character varying) RETURNS character varying LANGUAGE sql @@ -165,10 +152,7 @@ CONCAT( ); $$; - --- --- Name: scrub_text(character varying); Type: FUNCTION; Schema: rideshare; Owner: - --- +-- Name: scrub_text(character varying); Type: FUNCTION CREATE FUNCTION rideshare.scrub_text(input character varying) RETURNS character varying LANGUAGE sql @@ -182,14 +166,9 @@ SUBSTR( ); $$; - SET default_tablespace = ''; -SET default_table_access_method = heap; - --- --- Name: ar_internal_metadata; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: ar_internal_metadata; Type: TABLE CREATE TABLE rideshare.ar_internal_metadata ( key character varying NOT NULL, @@ -198,13 +177,10 @@ CREATE TABLE rideshare.ar_internal_metadata ( updated_at timestamp(6) without time zone NOT NULL ); - --- --- Name: trips; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: trips; Type: TABLE CREATE TABLE rideshare.trips ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, trip_request_id bigint NOT NULL, driver_id integer NOT NULL, completed_at timestamp without time zone, @@ -214,13 +190,10 @@ CREATE TABLE rideshare.trips ( CONSTRAINT rating_check CHECK (((rating >= 1) AND (rating <= 5))) ); - --- --- Name: users; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: users; Type: TABLE CREATE TABLE rideshare.users ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, first_name character varying NOT NULL, last_name character varying NOT NULL, email character varying NOT NULL, @@ -232,17 +205,11 @@ CREATE TABLE rideshare.users ( drivers_license_number character varying(100) ); - --- --- Name: TABLE users; Type: COMMENT; Schema: rideshare; Owner: - --- +-- Name: TABLE users; Type: COMMENT COMMENT ON TABLE rideshare.users IS 'sensitive_fields|first_name:scrub_text,last_name:scrub_text,email:scrub_email'; - --- --- Name: fast_search_results; Type: MATERIALIZED VIEW; Schema: rideshare; Owner: - --- +-- Name: fast_search_results; Type: MATERIALIZED VIEW CREATE MATERIALIZED VIEW rideshare.fast_search_results AS SELECT t.driver_id, @@ -255,13 +222,10 @@ CREATE MATERIALIZED VIEW rideshare.fast_search_results AS ORDER BY (count(t.rating)) DESC WITH NO DATA; - --- --- Name: locations; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: locations; Type: TABLE CREATE TABLE rideshare.locations ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, address character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, @@ -271,38 +235,13 @@ CREATE TABLE rideshare.locations ( CONSTRAINT state_length_check CHECK ((length(state) = 2)) ); - --- --- Name: locations_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.locations_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: locations_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.locations_id_seq OWNED BY rideshare.locations.id; - - --- --- Name: schema_migrations; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: schema_migrations; Type: TABLE CREATE TABLE rideshare.schema_migrations ( version character varying NOT NULL ); - --- --- Name: search_results; Type: VIEW; Schema: rideshare; Owner: - --- +-- Name: search_results; Type: VIEW CREATE VIEW rideshare.search_results AS SELECT concat(d.first_name, ' ', d.last_name) AS driver_name, @@ -313,45 +252,20 @@ CREATE VIEW rideshare.search_results AS GROUP BY t.driver_id, d.first_name, d.last_name ORDER BY (count(t.rating)) DESC; - --- --- Name: trip_positions; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: trip_positions; Type: TABLE CREATE TABLE rideshare.trip_positions ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, "position" point NOT NULL, trip_id bigint NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); - --- --- Name: trip_positions_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.trip_positions_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: trip_positions_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.trip_positions_id_seq OWNED BY rideshare.trip_positions.id; - - --- --- Name: trip_requests; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: trip_requests; Type: TABLE CREATE TABLE rideshare.trip_requests ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, rider_id integer NOT NULL, start_location_id integer NOT NULL, end_location_id integer NOT NULL, @@ -359,70 +273,10 @@ CREATE TABLE rideshare.trip_requests ( updated_at timestamp(6) without time zone NOT NULL ); - --- --- Name: trip_requests_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.trip_requests_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: trip_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.trip_requests_id_seq OWNED BY rideshare.trip_requests.id; - - --- --- Name: trips_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.trips_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: trips_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.trips_id_seq OWNED BY rideshare.trips.id; - - --- --- Name: users_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.users_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.users_id_seq OWNED BY rideshare.users.id; - - --- --- Name: vehicle_reservations; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: vehicle_reservations; Type: TABLE CREATE TABLE rideshare.vehicle_reservations ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, vehicle_id integer NOT NULL, trip_request_id integer NOT NULL, canceled boolean DEFAULT false NOT NULL, @@ -432,346 +286,121 @@ CREATE TABLE rideshare.vehicle_reservations ( updated_at timestamp(6) without time zone NOT NULL ); - --- --- Name: vehicle_reservations_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.vehicle_reservations_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: vehicle_reservations_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.vehicle_reservations_id_seq OWNED BY rideshare.vehicle_reservations.id; - - --- --- Name: vehicles; Type: TABLE; Schema: rideshare; Owner: - --- +-- Name: vehicles; Type: TABLE CREATE TABLE rideshare.vehicles ( - id bigint NOT NULL, + id BIGSERIAL PRIMARY KEY, name character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, status rideshare.vehicle_status DEFAULT 'draft'::rideshare.vehicle_status NOT NULL ); - --- --- Name: vehicles_id_seq; Type: SEQUENCE; Schema: rideshare; Owner: - --- - -CREATE SEQUENCE rideshare.vehicles_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: vehicles_id_seq; Type: SEQUENCE OWNED BY; Schema: rideshare; Owner: - --- - -ALTER SEQUENCE rideshare.vehicles_id_seq OWNED BY rideshare.vehicles.id; - - --- --- Name: locations id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.locations ALTER COLUMN id SET DEFAULT nextval('rideshare.locations_id_seq'::regclass); - - --- --- Name: trip_positions id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trip_positions ALTER COLUMN id SET DEFAULT nextval('rideshare.trip_positions_id_seq'::regclass); - - --- --- Name: trip_requests id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trip_requests ALTER COLUMN id SET DEFAULT nextval('rideshare.trip_requests_id_seq'::regclass); - - --- --- Name: trips id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trips ALTER COLUMN id SET DEFAULT nextval('rideshare.trips_id_seq'::regclass); - - --- --- Name: users id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.users ALTER COLUMN id SET DEFAULT nextval('rideshare.users_id_seq'::regclass); - - --- --- Name: vehicle_reservations id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.vehicle_reservations ALTER COLUMN id SET DEFAULT nextval('rideshare.vehicle_reservations_id_seq'::regclass); - - --- --- Name: vehicles id; Type: DEFAULT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.vehicles ALTER COLUMN id SET DEFAULT nextval('rideshare.vehicles_id_seq'::regclass); - - --- --- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - ALTER TABLE ONLY rideshare.ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); - --- --- Name: trips chk_rails_4743ddc2d2; Type: CHECK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trips chk_rails_4743ddc2d2; Type: CHECK CONSTRAINT ALTER TABLE rideshare.trips ADD CONSTRAINT chk_rails_4743ddc2d2 CHECK ((completed_at > created_at)) NOT VALID; - --- --- Name: locations locations_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.locations - ADD CONSTRAINT locations_pkey PRIMARY KEY (id); - - --- --- Name: vehicle_reservations non_overlapping_vehicle_registration; Type: CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: vehicle_reservations non_overlapping_vehicle_registration; Type: CONSTRAINT ALTER TABLE ONLY rideshare.vehicle_reservations ADD CONSTRAINT non_overlapping_vehicle_registration EXCLUDE USING gist (int4range(vehicle_id, vehicle_id, '[]'::text) WITH =, tstzrange(starts_at, ends_at) WITH &&) WHERE ((NOT canceled)); - --- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - ALTER TABLE ONLY rideshare.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); - --- --- Name: trip_positions trip_positions_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trip_positions - ADD CONSTRAINT trip_positions_pkey PRIMARY KEY (id); - - --- --- Name: trip_requests trip_requests_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trip_requests - ADD CONSTRAINT trip_requests_pkey PRIMARY KEY (id); - - --- --- Name: trips trips_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.trips - ADD CONSTRAINT trips_pkey PRIMARY KEY (id); - - --- --- Name: users users_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.users - ADD CONSTRAINT users_pkey PRIMARY KEY (id); - - --- --- Name: vehicle_reservations vehicle_reservations_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.vehicle_reservations - ADD CONSTRAINT vehicle_reservations_pkey PRIMARY KEY (id); - - --- --- Name: vehicles vehicles_pkey; Type: CONSTRAINT; Schema: rideshare; Owner: - --- - -ALTER TABLE ONLY rideshare.vehicles - ADD CONSTRAINT vehicles_pkey PRIMARY KEY (id); - - --- --- Name: index_fast_search_results_on_driver_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_fast_search_results_on_driver_id; Type: INDEX CREATE UNIQUE INDEX index_fast_search_results_on_driver_id ON rideshare.fast_search_results USING btree (driver_id); - --- --- Name: index_locations_on_address; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_locations_on_address; Type: INDEX CREATE UNIQUE INDEX index_locations_on_address ON rideshare.locations USING btree (address); - --- --- Name: index_trip_requests_on_end_location_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trip_requests_on_end_location_id; Type: INDEX CREATE INDEX index_trip_requests_on_end_location_id ON rideshare.trip_requests USING btree (end_location_id); - --- --- Name: index_trip_requests_on_rider_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trip_requests_on_rider_id; Type: INDEX CREATE INDEX index_trip_requests_on_rider_id ON rideshare.trip_requests USING btree (rider_id); - --- --- Name: index_trip_requests_on_start_location_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trip_requests_on_start_location_id; Type: INDEX CREATE INDEX index_trip_requests_on_start_location_id ON rideshare.trip_requests USING btree (start_location_id); - --- --- Name: index_trips_on_driver_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trips_on_driver_id; Type: INDEX CREATE INDEX index_trips_on_driver_id ON rideshare.trips USING btree (driver_id); - --- --- Name: index_trips_on_rating; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trips_on_rating; Type: INDEX CREATE INDEX index_trips_on_rating ON rideshare.trips USING btree (rating); - --- --- Name: index_trips_on_trip_request_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_trips_on_trip_request_id; Type: INDEX CREATE INDEX index_trips_on_trip_request_id ON rideshare.trips USING btree (trip_request_id); - --- --- Name: index_users_on_email; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_users_on_email; Type: INDEX CREATE UNIQUE INDEX index_users_on_email ON rideshare.users USING btree (email); - --- --- Name: index_users_on_last_name; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_users_on_last_name; Type: INDEX CREATE INDEX index_users_on_last_name ON rideshare.users USING btree (last_name); - --- --- Name: index_vehicle_reservations_on_vehicle_id; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_vehicle_reservations_on_vehicle_id; Type: INDEX CREATE INDEX index_vehicle_reservations_on_vehicle_id ON rideshare.vehicle_reservations USING btree (vehicle_id); - --- --- Name: index_vehicles_on_name; Type: INDEX; Schema: rideshare; Owner: - --- +-- Name: index_vehicles_on_name; Type: INDEX CREATE UNIQUE INDEX index_vehicles_on_name ON rideshare.vehicles USING btree (name); - --- --- Name: trip_requests fk_rails_3fdebbfaca; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trip_requests fk_rails_3fdebbfaca; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trip_requests ADD CONSTRAINT fk_rails_3fdebbfaca FOREIGN KEY (end_location_id) REFERENCES rideshare.locations(id); - --- --- Name: vehicle_reservations fk_rails_59996232fc; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: vehicle_reservations fk_rails_59996232fc; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.vehicle_reservations ADD CONSTRAINT fk_rails_59996232fc FOREIGN KEY (trip_request_id) REFERENCES rideshare.trip_requests(id); - --- --- Name: trips fk_rails_6d92acb430; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trips fk_rails_6d92acb430; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trips ADD CONSTRAINT fk_rails_6d92acb430 FOREIGN KEY (trip_request_id) REFERENCES rideshare.trip_requests(id); - --- --- Name: vehicle_reservations fk_rails_7edc8e666a; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: vehicle_reservations fk_rails_7edc8e666a; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.vehicle_reservations ADD CONSTRAINT fk_rails_7edc8e666a FOREIGN KEY (vehicle_id) REFERENCES rideshare.vehicles(id); - --- --- Name: trip_positions fk_rails_9688ac8706; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trip_positions fk_rails_9688ac8706; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trip_positions ADD CONSTRAINT fk_rails_9688ac8706 FOREIGN KEY (trip_id) REFERENCES rideshare.trips(id); - --- --- Name: trip_requests fk_rails_c17a139554; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trip_requests fk_rails_c17a139554; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trip_requests ADD CONSTRAINT fk_rails_c17a139554 FOREIGN KEY (rider_id) REFERENCES rideshare.users(id); - --- --- Name: trips fk_rails_e7560abc33; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trips fk_rails_e7560abc33; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trips ADD CONSTRAINT fk_rails_e7560abc33 FOREIGN KEY (driver_id) REFERENCES rideshare.users(id); - --- --- Name: trip_requests fk_rails_fa2679b626; Type: FK CONSTRAINT; Schema: rideshare; Owner: - --- +-- Name: trip_requests fk_rails_fa2679b626; Type: FK CONSTRAINT ALTER TABLE ONLY rideshare.trip_requests ADD CONSTRAINT fk_rails_fa2679b626 FOREIGN KEY (start_location_id) REFERENCES rideshare.locations(id); - --- -- PostgreSQL database dump complete --- SET search_path TO rideshare; @@ -828,4 +457,3 @@ INSERT INTO "schema_migrations" (version) VALUES ('20191111151637'), ('20191108221519'), ('20191107212726'); - diff --git a/erd.pdf b/erd.pdf index 14ea9d1b63b08b99712c3500acc89b36c2e1210d..a92f0a171c42455e14714c37040892a85546c74c 100644 GIT binary patch delta 296 zcmV+@0oVSbr30d+1F-eae=%#rFcgG${fb*kouRg*#C8%)hBy#PDHtbP=^zy07>Z>i zxitU2k{zcMP4DBL?vBSmNtz?2goCAwq-!km6)6fN=UcCkRH9Lq07%~2i^T^xC~AC; zsMJH}z{qYlZd68J2B{1pDO#h!Vz!PcqN{Vg-6qLM8zcH_D{ZVzf3sLj-xwuatGk16 z3ejQ9DPK`ebC&T9qc1djrgSlz{KdkPw+{Q2Fe>B-$wu(5F0I(>A0LA>Y%<`sp{iCK%Y7AT3J09 usVtTc&y!!2Zi;UG6&3!~D}@tZy1BRW7r2-6qF+c(ZuFC}%oDR4(T4$BACCP1 delta 296 zcmV+@0oVSbr30d+1F-eaf6Z#cFc5_Aeu}x2I)~bl{M%r1NCKghLP&ZmJqTGif?^p- zF3sCla$=XF(|*iqW>^Xm6%`5+G0=iWMUAY=qozUnejOyzBk!b*0Hm*~wfF!7!3m!e z+Uc=(pwVVCZ5)kmM!hG|X=#0*u8s6I>c!}$bU*OCr=V|9vd-<(|JRP Date: Wed, 28 Aug 2024 21:22:06 -0500 Subject: [PATCH 2/3] Update activerecord-clean-db-structure Installing activerecord-clean-db-structure 0.4.1 (was 0.4.0) --- Gemfile | 3 +-- Gemfile.lock | 15 +++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 2678f67..b6d55e8 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,7 @@ gem 'pg_query', '~> 5.1' gem 'pg_search', '~> 2.3' gem 'activerecord-import', '~> 1.5' -# Gem has an unreleased fix https://github.com/lfittl/activerecord-clean-db-structure/pull/36 -gem 'activerecord-clean-db-structure', git: 'git@github.com:lfittl/activerecord-clean-db-structure.git' +gem 'activerecord-clean-db-structure', '~> 0.4' # assets gems default Rails 7 app gem 'sprockets-rails', '~> 3.4' diff --git a/Gemfile.lock b/Gemfile.lock index 1b4fa28..372ba01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,3 @@ -GIT - remote: git@github.com:lfittl/activerecord-clean-db-structure.git - revision: ed6959ee644787cdf243b77eb61eed3775f394c9 - specs: - activerecord-clean-db-structure (0.4.0) - activerecord (>= 4.2) - GIT remote: https://github.com/andyatkinson/pghero.git revision: 49336df1ca79c3185a1d6b3c0fb87007ef09c7df @@ -83,6 +76,8 @@ GEM activemodel (= 7.1.3.4) activesupport (= 7.1.3.4) timeout (>= 0.4.0) + activerecord-clean-db-structure (0.4.1) + activerecord (>= 4.2) activerecord-import (1.7.0) activerecord (>= 4.2) activestorage (7.1.3.4) @@ -113,7 +108,7 @@ GEM code_analyzer (0.5.5) sexp_processor coderay (1.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) csv (3.3.0) @@ -184,7 +179,7 @@ GEM memory_profiler (1.0.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.24.1) + minitest (5.25.1) mutex_m (0.2.0) net-http (0.4.1) uri @@ -331,7 +326,7 @@ PLATFORMS DEPENDENCIES active_record_doctor - activerecord-clean-db-structure! + activerecord-clean-db-structure (~> 0.4) activerecord-import (~> 1.5) bcrypt (~> 3.1) benchmark-ips From c4754e67701d518494c9be11edd077b44f38f631 Mon Sep 17 00:00:00 2001 From: Andy Atkinson Date: Sun, 22 Sep 2024 14:17:02 -0500 Subject: [PATCH 3/3] Use newer released version --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index b6d55e8..f9ac9f0 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'pg_query', '~> 5.1' gem 'pg_search', '~> 2.3' gem 'activerecord-import', '~> 1.5' -gem 'activerecord-clean-db-structure', '~> 0.4' +gem 'activerecord-clean-db-structure', '~> 0.4.3' # assets gems default Rails 7 app gem 'sprockets-rails', '~> 3.4' diff --git a/Gemfile.lock b/Gemfile.lock index 33ff13d..5e8d10c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,7 +76,7 @@ GEM activemodel (= 7.1.3.4) activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activerecord-clean-db-structure (0.4.1) + activerecord-clean-db-structure (0.4.3) activerecord (>= 4.2) activerecord-import (1.7.0) activerecord (>= 4.2) @@ -153,7 +153,7 @@ GEM google-protobuf (4.27.2-x86_64-linux) bigdecimal rake (>= 13) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) importmap-rails (1.2.3) actionpack (>= 6.0.0) @@ -326,7 +326,7 @@ PLATFORMS DEPENDENCIES active_record_doctor - activerecord-clean-db-structure (~> 0.4) + activerecord-clean-db-structure (~> 0.4.3) activerecord-import (~> 1.5) bcrypt (~> 3.1) benchmark-ips