mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
parent
5fdc1938af
commit
5a533e09bf
44 changed files with 1027 additions and 375 deletions
23
db/migrate/20170423225333_add_zone_to_prices.rb
Normal file
23
db/migrate/20170423225333_add_zone_to_prices.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
class AddZoneToPrices < ActiveRecord::Migration
|
||||
def up
|
||||
add_reference :prices, :zone, index: true
|
||||
add_foreign_key :prices, :zones
|
||||
assign_zone_to_current_prices
|
||||
change_column :prices, :zone_id, :integer, null: false
|
||||
remove_column :prices, :category, :string
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_zone_to_current_prices
|
||||
Billing::Price.all.each do |price|
|
||||
zone = DNS::Zone.find_by!(origin: price.category)
|
||||
price.zone = zone
|
||||
price.save!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -963,7 +963,6 @@ ActiveRecord::Schema.define(version: 20170424115801) do
|
|||
|
||||
create_table "prices", force: :cascade do |t|
|
||||
t.string "desc"
|
||||
t.string "category"
|
||||
t.integer "price_cents", null: false
|
||||
t.datetime "valid_from"
|
||||
t.datetime "valid_to"
|
||||
|
@ -973,8 +972,11 @@ ActiveRecord::Schema.define(version: 20170424115801) do
|
|||
t.datetime "updated_at", null: false
|
||||
t.string "duration"
|
||||
t.string "operation_category"
|
||||
t.integer "zone_id", null: false
|
||||
end
|
||||
|
||||
add_index "prices", ["zone_id"], name: "index_prices_on_zone_id", using: :btree
|
||||
|
||||
create_table "que_jobs", id: false, force: :cascade do |t|
|
||||
t.integer "priority", limit: 2, default: 100, null: false
|
||||
t.datetime "run_at", default: "now()", null: false
|
||||
|
@ -1132,4 +1134,5 @@ ActiveRecord::Schema.define(version: 20170424115801) do
|
|||
|
||||
add_index "zones", ["origin"], name: "unique_zone_origin", unique: true, using: :btree
|
||||
|
||||
add_foreign_key "prices", "zones"
|
||||
end
|
||||
|
|
|
@ -2490,13 +2490,12 @@ ALTER SEQUENCE people_id_seq OWNED BY people.id;
|
|||
|
||||
|
||||
--
|
||||
-- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE prices (
|
||||
id integer NOT NULL,
|
||||
"desc" character varying,
|
||||
category character varying,
|
||||
price_cents integer NOT NULL,
|
||||
valid_from timestamp without time zone,
|
||||
valid_to timestamp without time zone,
|
||||
|
@ -2505,7 +2504,8 @@ CREATE TABLE prices (
|
|||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
duration interval,
|
||||
operation_category character varying
|
||||
operation_category character varying,
|
||||
zone_id integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
@ -3852,7 +3852,7 @@ ALTER TABLE ONLY people
|
|||
|
||||
|
||||
--
|
||||
-- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY prices
|
||||
|
@ -3900,7 +3900,7 @@ ALTER TABLE ONLY settings
|
|||
|
||||
|
||||
--
|
||||
-- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY zones
|
||||
|
@ -4605,6 +4605,13 @@ CREATE UNIQUE INDEX index_people_on_email ON people USING btree (email);
|
|||
CREATE UNIQUE INDEX index_people_on_reset_password_token ON people USING btree (reset_password_token);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_prices_on_zone_id ON prices USING btree (zone_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_registrant_verifications_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
@ -4710,6 +4717,14 @@ CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (versi
|
|||
CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version);
|
||||
|
||||
|
||||
--
|
||||
-- Name: fk_rails_78c376257f; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY prices
|
||||
ADD CONSTRAINT fk_rails_78c376257f FOREIGN KEY (zone_id) REFERENCES zones(id);
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
@ -5188,5 +5203,7 @@ INSERT INTO schema_migrations (version) VALUES ('20170423214500');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170423222302');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170423225333');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170424115801');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue