Improve "accounts" DB table structure

#475
This commit is contained in:
Artur Beljajev 2017-05-07 00:26:47 +03:00
parent 3162c76bbf
commit 261c3cc157
2 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,6 @@
class AddAccountRegistrarFk < ActiveRecord::Migration
def change
change_column :accounts, :registrar_id, :integer, null: false
add_foreign_key :accounts, :registrars
end
end

View file

@ -327,7 +327,7 @@ ALTER SEQUENCE account_activities_id_seq OWNED BY account_activities.id;
CREATE TABLE accounts (
id integer NOT NULL,
registrar_id integer,
registrar_id integer NOT NULL,
account_type character varying,
balance numeric(10,2) DEFAULT 0.0 NOT NULL,
created_at timestamp without time zone,
@ -4792,6 +4792,14 @@ ALTER TABLE ONLY account_activities
ADD CONSTRAINT fk_rails_b80dbb973d FOREIGN KEY (bank_transaction_id) REFERENCES bank_transactions(id);
--
-- Name: fk_rails_c9f635c0b3; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY accounts
ADD CONSTRAINT fk_rails_c9f635c0b3 FOREIGN KEY (registrar_id) REFERENCES registrars(id);
--
-- Name: fk_rails_ce38d749f6; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -5298,3 +5306,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170506205356');
INSERT INTO schema_migrations (version) VALUES ('20170506205946');
INSERT INTO schema_migrations (version) VALUES ('20170506212014');