From 4e18a03de6f315de9d7d7db2aacadbb680d3fd8a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 7 Jun 2021 15:03:48 +0200 Subject: [PATCH] fix ADMINSYS script --- db/structure.sql | 117 ++++++++++++++++++++++++++++++++----- scripts/rename-adminsys.sh | 11 +++- 2 files changed, 112 insertions(+), 16 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index 915c89b11..0542fca31 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1467,7 +1467,8 @@ CREATE TABLE public.payment_gateway_objects ( gateway_object_id character varying, gateway_object_type character varying, item_type character varying, - item_id bigint + item_id bigint, + payment_gateway_object_id bigint ); @@ -1529,6 +1530,41 @@ CREATE SEQUENCE public.payment_schedule_items_id_seq ALTER SEQUENCE public.payment_schedule_items_id_seq OWNED BY public.payment_schedule_items.id; +-- +-- Name: payment_schedule_objects; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.payment_schedule_objects ( + id bigint NOT NULL, + object_type character varying, + object_id bigint, + payment_schedule_id bigint, + main boolean, + footprint character varying, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +-- +-- Name: payment_schedule_objects_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.payment_schedule_objects_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: payment_schedule_objects_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.payment_schedule_objects_id_seq OWNED BY public.payment_schedule_objects.id; + + -- -- Name: payment_schedules; Type: TABLE; Schema: public; Owner: - -- @@ -1547,9 +1583,7 @@ CREATE TABLE public.payment_schedules ( statistic_profile_id bigint, operator_profile_id bigint, created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, - scheduled_id integer, - scheduled_type character varying + updated_at timestamp without time zone NOT NULL ); @@ -2973,9 +3007,7 @@ CREATE TABLE public.wallet_transactions ( amount integer, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, - invoicing_profile_id integer, - transactable_type character varying, - transactable_id bigint + invoicing_profile_id integer ); @@ -3317,6 +3349,13 @@ ALTER TABLE ONLY public.payment_gateway_objects ALTER COLUMN id SET DEFAULT next ALTER TABLE ONLY public.payment_schedule_items ALTER COLUMN id SET DEFAULT nextval('public.payment_schedule_items_id_seq'::regclass); +-- +-- Name: payment_schedule_objects id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.payment_schedule_objects ALTER COLUMN id SET DEFAULT nextval('public.payment_schedule_objects_id_seq'::regclass); + + -- -- Name: payment_schedules id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3954,6 +3993,14 @@ ALTER TABLE ONLY public.payment_schedule_items ADD CONSTRAINT payment_schedule_items_pkey PRIMARY KEY (id); +-- +-- Name: payment_schedule_objects payment_schedule_objects_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.payment_schedule_objects + ADD CONSTRAINT payment_schedule_objects_pkey PRIMARY KEY (id); + + -- -- Name: payment_schedules payment_schedules_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4593,6 +4640,13 @@ CREATE INDEX index_organizations_on_invoicing_profile_id ON public.organizations CREATE INDEX index_payment_gateway_objects_on_item_type_and_item_id ON public.payment_gateway_objects USING btree (item_type, item_id); +-- +-- Name: index_payment_gateway_objects_on_payment_gateway_object_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_payment_gateway_objects_on_payment_gateway_object_id ON public.payment_gateway_objects USING btree (payment_gateway_object_id); + + -- -- Name: index_payment_schedule_items_on_invoice_id; Type: INDEX; Schema: public; Owner: - -- @@ -4607,6 +4661,20 @@ CREATE INDEX index_payment_schedule_items_on_invoice_id ON public.payment_schedu CREATE INDEX index_payment_schedule_items_on_payment_schedule_id ON public.payment_schedule_items USING btree (payment_schedule_id); +-- +-- Name: index_payment_schedule_objects_on_object_type_and_object_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_payment_schedule_objects_on_object_type_and_object_id ON public.payment_schedule_objects USING btree (object_type, object_id); + + +-- +-- Name: index_payment_schedule_objects_on_payment_schedule_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_payment_schedule_objects_on_payment_schedule_id ON public.payment_schedule_objects USING btree (payment_schedule_id); + + -- -- Name: index_payment_schedules_on_coupon_id; Type: INDEX; Schema: public; Owner: - -- @@ -5118,13 +5186,6 @@ CREATE INDEX index_users_roles_on_user_id_and_role_id ON public.users_roles USIN CREATE INDEX index_wallet_transactions_on_invoicing_profile_id ON public.wallet_transactions USING btree (invoicing_profile_id); --- --- Name: index_wallet_transactions_on_transactable; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_wallet_transactions_on_transactable ON public.wallet_transactions USING btree (transactable_type, transactable_id); - - -- -- Name: index_wallet_transactions_on_wallet_id; Type: INDEX; Schema: public; Owner: - -- @@ -5160,6 +5221,14 @@ CREATE INDEX profiles_lower_unaccent_last_name_trgm_idx ON public.profiles USING CREATE INDEX projects_search_vector_idx ON public.projects USING gin (search_vector); +-- +-- Name: accounting_periods accounting_periods_del_protect; Type: RULE; Schema: public; Owner: - +-- + +CREATE RULE accounting_periods_del_protect AS + ON DELETE TO public.accounting_periods DO INSTEAD NOTHING; + + -- -- Name: projects projects_search_content_trigger; Type: TRIGGER; Schema: public; Owner: - -- @@ -5279,6 +5348,14 @@ ALTER TABLE ONLY public.payment_schedules ADD CONSTRAINT fk_rails_27cdd051f7 FOREIGN KEY (statistic_profile_id) REFERENCES public.statistic_profiles(id); +-- +-- Name: payment_gateway_objects fk_rails_2a54622221; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.payment_gateway_objects + ADD CONSTRAINT fk_rails_2a54622221 FOREIGN KEY (payment_gateway_object_id) REFERENCES public.payment_gateway_objects(id); + + -- -- Name: statistic_profiles fk_rails_2c8874d1a1; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5367,6 +5444,14 @@ ALTER TABLE ONLY public.payment_schedules ADD CONSTRAINT fk_rails_552bc65163 FOREIGN KEY (coupon_id) REFERENCES public.coupons(id); +-- +-- Name: payment_schedule_objects fk_rails_56f6b6d2d2; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.payment_schedule_objects + ADD CONSTRAINT fk_rails_56f6b6d2d2 FOREIGN KEY (payment_schedule_id) REFERENCES public.payment_schedules(id); + + -- -- Name: tickets fk_rails_65422fe751; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5928,6 +6013,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('20201112092002'), ('20210416073410'), ('20210416083610'), -('20210521085710'); +('20210521085710'), +('20210525134018'), +('20210525150942'); diff --git a/scripts/rename-adminsys.sh b/scripts/rename-adminsys.sh index 572556442..0035a1b78 100644 --- a/scripts/rename-adminsys.sh +++ b/scripts/rename-adminsys.sh @@ -9,11 +9,20 @@ config() echo "Please run this script from the installation folder, and as a user having write access on config/env" exit 1 fi + local _commands=("sed" "grep") + for _command in "${_commands[@]}"; do + echo "detecting $_command..." + if ! command -v "$_command" + then + echo "Please install $_command before running this script." + echo -e "\e[91m[ ❌ ] $_command was not found, exiting...\e[39m" && exit 1 + fi + done } rename_var() { - current=$(grep "SUPERADMIN_EMAIL=" "$FABMANAGER_PATH/config/env") + current=$(grep -Po "SUPERADMIN_EMAIL=\K.*" "$FABMANAGER_PATH/config/env") sed -i.bak "s/SUPERADMIN_EMAIL=$current/ADMINSYS_EMAIL=$current/g" "$FABMANAGER_PATH/config/env" }