<commit_before>/*Connect to database*/
\connect mobydq



/*Create user group*/
INSERT INTO base.user_group (name) VALUES ('user_group_example');

/*Create user*/
INSERT INTO base.user (email, oauth_type, access_token, refresh_token, expiry_date) VALUES
('<EMAIL>', 'GOOGLE', '', 0, '2999-12-31');

/*Grant role and user group to user*/
DO $$
DECLARE
  user_id TEXT;
  user_group_id TEXT;
BEGIN
  SELECT id INTO user_id FROM base.user WHERE email='<EMAIL>';
  EXECUTE 'GRANT standard TO user_ ||' user_id;

  SELECT id INTO user_group_id FROM base.user_group WHERE name='user_group_example';
  EXECUTE 'GRANT user_group_' || user_group_id || ' TO user_' || user_id;
END;
$$;


/*Create data source*/
INSERT INTO base.data_source (name, connection_string, login, password, data_source_type_id, user_group) VALUES
(
   'dq_example_microsoft_sql_server'
  ,'driver={FreeTDS};server=db-sql-server;port=1433;database=star_wars;tds_version=8.0;'
  ,'sa'
  ,'1234-abcd'
  ,4  -- Microsoft SQL Server
  ,'user_group_example'<commit_msg>Remove manual role assignment since it's done via trigger<commit_after>/*Connect to database*/
\connect mobydq



/*Create user group*/
INSERT INTO base.user_group (name) VALUES ('user_group_example');

/*Create user*/
INSERT INTO base.user (email, oauth_type, access_token, refresh_token, expiry_date) VALUES
('<EMAIL>', 'GOOGLE', '', 0, '2999-12-31');

/*Assign group to user*/
DO $$
DECLARE
  user_id TEXT;
  user_group_id TEXT;
BEGIN
  SELECT id INTO user_id FROM base.user WHERE email='<EMAIL>';
  SELECT id INTO user_group_id FROM base.user_group WHERE name='user_group_example';
  EXECUTE 'GRANT user_group_' || user_group_id || ' TO user_' || user_id;
END;
$$;



/*Create data source*/
INSERT INTO base.data_source (name, connection_string, login, password, data_source_type_id, user_group) VALUES
(
   'dq_example_microsoft_sql_server'
  ,'driver={FreeTDS};server=db-sql-server;port=1433;database=star_wars;tds_version=8.0;'
  ,'sa'
  ,'1234-abcd'
  ,4  -- Microsoft SQL Server
  ,'user_group_example'
{'fraction_non_alphanumeric': 0.131436978911231, 'fraction_numerical': 0.0196174595389897, 'mean_word_length': 5.355140186915888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3356641', 'n_tokens_mistral': 772, 'n_tokens_neox': 697, 'n_words': 188}