Skip to content

Commit

Permalink
fix: 🚑 make the setup script work on channel-service
Browse files Browse the repository at this point in the history
  • Loading branch information
EmperorRXF committed Aug 7, 2024
1 parent 696958c commit ef2932c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion services/channel/service/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
pick,
} from '@axinom/mosaic-service-common';
import { serviceAccountSetup } from '../../../../scripts/helpers';
import { getConfigDefinitions } from '../src/common';
import { getConfigDefinitions } from '../src/common/config';

async function main(): Promise<void> {
const config = getValidatedConfig(
Expand Down
27 changes: 8 additions & 19 deletions services/channel/service/src/generated/db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ $_$;


--
-- Name: define_publish_trigger(text, text); Type: FUNCTION; Schema: app_hidden; Owner: -
-- Name: define_publish_trigger(text, text, text); Type: FUNCTION; Schema: app_hidden; Owner: -
--

CREATE FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text) RETURNS void
CREATE FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text, columnnames text) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
EXECUTE 'DROP TRIGGER IF EXISTS _900__publish_user ON ' || schemaName || '.' || tableName || ';';
EXECUTE 'CREATE trigger _900__publish_user BEFORE INSERT OR UPDATE ON ' || schemaName || '.' || tableName ||
EXECUTE 'CREATE trigger _900__publish_user BEFORE INSERT OR UPDATE OF ' || columnNames || ' ON ' || schemaName || '.' || tableName ||
' FOR EACH ROW EXECUTE PROCEDURE app_hidden.tg__publish_audit_fields();';
END;
$$;
Expand Down Expand Up @@ -835,17 +835,6 @@ BEGIN
IF NEW.published_date = OLD.published_date AND NEW.updated_date <> OLD.updated_date THEN
NEW.publication_state = 'CHANGED';
END IF;

-- set published_user when published_date changes
IF NEW.published_date IS NULL THEN
NEW.published_user = NULL;
ELSIF OLD.published_date IS NULL OR NEW.published_date <> OLD.published_date THEN
IF username IS NULL OR username !~* '.*\S.*' THEN -- if username is null or empty string
NEW.published_user = 'Unknown';
ELSE
NEW.published_user = username;
END IF;
END IF;
RETURN NEW;
END;
$$;
Expand Down Expand Up @@ -3642,14 +3631,14 @@ CREATE TRIGGER _500_gql_programs_updated AFTER UPDATE ON app_public.programs FOR
-- Name: channels _900__publish_user; Type: TRIGGER; Schema: app_public; Owner: -
--

CREATE TRIGGER _900__publish_user BEFORE INSERT OR UPDATE ON app_public.channels FOR EACH ROW EXECUTE FUNCTION app_hidden.tg__publish_audit_fields();
CREATE TRIGGER _900__publish_user BEFORE INSERT OR UPDATE OF title, description, placeholder_video_id, is_drm_protected ON app_public.channels FOR EACH ROW EXECUTE FUNCTION app_hidden.tg__publish_audit_fields();


--
-- Name: playlists _900__publish_user; Type: TRIGGER; Schema: app_public; Owner: -
--

CREATE TRIGGER _900__publish_user BEFORE INSERT OR UPDATE ON app_public.playlists FOR EACH ROW EXECUTE FUNCTION app_hidden.tg__publish_audit_fields();
CREATE TRIGGER _900__publish_user BEFORE INSERT OR UPDATE OF title, start_date_time, calculated_duration_in_seconds, channel_id ON app_public.playlists FOR EACH ROW EXECUTE FUNCTION app_hidden.tg__publish_audit_fields();


--
Expand Down Expand Up @@ -3961,11 +3950,11 @@ GRANT ALL ON FUNCTION app_hidden.create_localizable_entity_triggers(aggregateid


--
-- Name: FUNCTION define_publish_trigger(tablename text, schemaname text); Type: ACL; Schema: app_hidden; Owner: -
-- Name: FUNCTION define_publish_trigger(tablename text, schemaname text, columnnames text); Type: ACL; Schema: app_hidden; Owner: -
--

REVOKE ALL ON FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text) FROM PUBLIC;
GRANT ALL ON FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text) TO channel_service_gql_role;
REVOKE ALL ON FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text, columnnames text) FROM PUBLIC;
GRANT ALL ON FUNCTION app_hidden.define_publish_trigger(tablename text, schemaname text, columnnames text) TO channel_service_gql_role;


--
Expand Down

0 comments on commit ef2932c

Please sign in to comment.