Replace index with constraint

#700
This commit is contained in:
Artur Beljajev 2018-02-12 17:50:48 +02:00
parent fa6edab62a
commit 5a101ddaf4
3 changed files with 30 additions and 7 deletions

View file

@ -0,0 +1,13 @@
class AddEppSessionsSessionIdUniqueConstraint < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE epp_sessions ADD CONSTRAINT unique_session_id UNIQUE (session_id)
SQL
end
def down
execute <<-SQL
ALTER TABLE epp_sessions DROP CONSTRAINT unique_session_id
SQL
end
end

View file

@ -0,0 +1,5 @@
class RemoveEppSessionsSessionIdUniqueIndex < ActiveRecord::Migration
def change
remove_index :epp_sessions, name: :index_epp_sessions_on_session_id
end
end

View file

@ -3634,6 +3634,14 @@ ALTER TABLE ONLY contacts
ADD CONSTRAINT unique_contact_code UNIQUE (code); ADD CONSTRAINT unique_contact_code UNIQUE (code);
--
-- Name: unique_session_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY epp_sessions
ADD CONSTRAINT unique_session_id UNIQUE (session_id);
-- --
-- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
@ -3885,13 +3893,6 @@ CREATE INDEX index_domains_on_registrar_id ON domains USING btree (registrar_id)
CREATE INDEX index_domains_on_statuses ON domains USING gin (statuses); CREATE INDEX index_domains_on_statuses ON domains USING gin (statuses);
--
-- Name: index_epp_sessions_on_session_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX index_epp_sessions_on_session_id ON epp_sessions USING btree (session_id);
-- --
-- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace:
-- --
@ -5087,3 +5088,7 @@ INSERT INTO schema_migrations (version) VALUES ('20180207072139');
INSERT INTO schema_migrations (version) VALUES ('20180212123810'); INSERT INTO schema_migrations (version) VALUES ('20180212123810');
INSERT INTO schema_migrations (version) VALUES ('20180212152810');
INSERT INTO schema_migrations (version) VALUES ('20180212154731');