USE WAREHOUSE DEV_CIEF_SNOWFLAKE_WH_XS;
USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE role accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."BOOKINGS";
copy into "RAW"."EXCHANGE_MYSQL"."BOOKINGS"
from @exchange_gcs_stage
pattern=".*exchange_production_bookings.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."COMPANIES";
copy into "RAW"."EXCHANGE_MYSQL"."COMPANIES"
from @exchange_gcs_stage
pattern=".*exchange_production_companies.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."CONTACTS";
copy into "RAW"."EXCHANGE_MYSQL"."CONTACTS"
from @exchange_gcs_stage
pattern=".*exchange_production_contacts.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."COUNTRIES";
copy into "RAW"."EXCHANGE_MYSQL"."COUNTRIES"
from @exchange_gcs_stage
pattern=".*exchange_production_countries.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."CURRENCIES";
copy into "RAW"."EXCHANGE_MYSQL"."CURRENCIES"
from @exchange_gcs_stage
pattern=".*exchange_production_currencies.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."CURRENCY_RATES";
copy into "RAW"."EXCHANGE_MYSQL"."CURRENCY_RATES"
from @exchange_gcs_stage
pattern=".*exchange_production_currency_rates.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."CURRENCY_RATE_LOGS";
copy into "RAW"."EXCHANGE_MYSQL"."CURRENCY_RATE_LOGS"
from @exchange_gcs_stage
pattern=".*exchange_production_currency_rate_logs.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."EMPLOYEES";
copy into "RAW"."EXCHANGE_MYSQL"."EMPLOYEES"
from @exchange_gcs_stage
pattern=".*exchange_production_employees.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."GROUPS";
copy into "RAW"."EXCHANGE_MYSQL"."GROUPS"
from @exchange_gcs_stage
pattern=".*exchange_production_groups.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."GROUP_TRANSACTIONS";
copy into "RAW"."EXCHANGE_MYSQL"."GROUP_TRANSACTIONS"
from @exchange_gcs_stage
pattern=".*exchange_production_group_transactions.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."SEGMENTS";
copy into "RAW"."EXCHANGE_MYSQL"."SEGMENTS"
from @exchange_gcs_stage
pattern=".*exchange_production_segments.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."SEGMENT_COMPANIES";
copy into "RAW"."EXCHANGE_MYSQL"."SEGMENT_COMPANIES"
from @exchange_gcs_stage
pattern=".*exchange_production_segment_companies.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."SERVICE_TYPES";
copy into "RAW"."EXCHANGE_MYSQL"."SERVICE_TYPES"
from @exchange_gcs_stage
pattern=".*exchange_production_service_types.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."TRANSACTIONS";
copy into "RAW"."EXCHANGE_MYSQL"."TRANSACTIONS"
from @exchange_gcs_stage
pattern=".*exchange_production_transactions.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."TRANSACTION_DETAIL";
copy into "RAW"."EXCHANGE_MYSQL"."TRANSACTION_DETAIL"
from @exchange_gcs_stage
pattern=".*exchange_production_transaction_detail.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."USERS";
copy into "RAW"."EXCHANGE_MYSQL"."USERS"
from @exchange_gcs_stage
pattern=".*exchange_production_users.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."USER_EMAIL_VERIFICATIONS";
copy into "RAW"."EXCHANGE_MYSQL"."USER_EMAIL_VERIFICATIONS"
from @exchange_gcs_stage
pattern=".*exchange_production_user_email_verifications.csv";

USE DATABASE DEV_CIEF_RAW_DB;
USE SCHEMA EXCHANGE_MYSQL;
USE ROLE accountadmin;
delete from "RAW"."EXCHANGE_MYSQL"."WALLETS";
copy into "RAW"."EXCHANGE_MYSQL"."WALLETS"
from @exchange_gcs_stage
pattern=".*exchange_production_wallets.csv";