mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
init from dbt cloud hosting repo
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
-- IMPORTS
|
||||
WITH activity_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'activity_log') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
activity_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
activity_logs.id,
|
||||
activity_logs.log_name,
|
||||
activity_logs.description,
|
||||
activity_logs.subject_id,
|
||||
activity_logs.subject_type,
|
||||
activity_logs.causer_id,
|
||||
activity_logs.causer_type,
|
||||
activity_logs.properties,
|
||||
activity_logs.created_at,
|
||||
activity_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM activity_logs
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__activity_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
log_name,
|
||||
description,
|
||||
subject_id,
|
||||
subject_type,
|
||||
causer_id,
|
||||
causer_type,
|
||||
properties,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM activity_logs_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__activity_logs
|
||||
@@ -0,0 +1,48 @@
|
||||
-- IMPORTS
|
||||
WITH addresses AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'addresses') }}
|
||||
),
|
||||
|
||||
-- LOGIC
|
||||
addresses_rename AS (
|
||||
|
||||
SELECT
|
||||
addresses.id,
|
||||
addresses.company_id,
|
||||
addresses.country_id,
|
||||
addresses.state_id,
|
||||
addresses.district_id,
|
||||
addresses.postcode,
|
||||
addresses.street_one AS address_line_one,
|
||||
addresses.street_two AS address_line_two,
|
||||
addresses.billing AS is_billing_address,
|
||||
addresses.deleted_at,
|
||||
addresses.created_at,
|
||||
addresses.updated_At,
|
||||
current_timestamp() as _dbt_ran_at
|
||||
|
||||
FROM addresses
|
||||
),
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__addresses AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
country_id,
|
||||
state_id,
|
||||
district_id,
|
||||
postcode,
|
||||
address_line_one,
|
||||
address_line_two,
|
||||
is_billing_address,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_At,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM addresses_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__addresses
|
||||
@@ -0,0 +1,34 @@
|
||||
-- IMPORTS
|
||||
WITH announcement_segments AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'announcement_segment') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
announcement_segments_rename AS (
|
||||
|
||||
SELECT
|
||||
announcement_segments.announcement_id,
|
||||
announcement_segments.segment_id,
|
||||
announcement_segments.created_at,
|
||||
announcement_segments.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM announcement_segments
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__announcement_segments AS (
|
||||
|
||||
SELECT
|
||||
announcement_id,
|
||||
segment_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM announcement_segments_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__announcement_segments
|
||||
@@ -0,0 +1,50 @@
|
||||
-- IMPORTS
|
||||
WITH announcements AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'announcements') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
announcements_rename AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
starting_on AS started_at,
|
||||
ending_on AS ended_at,
|
||||
is_all_day,
|
||||
duration,
|
||||
is_recurring,
|
||||
recurrence_pattern,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
current_timestamp() as _dbt_ran_at
|
||||
|
||||
FROM announcements
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__announcements AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
started_at,
|
||||
ended_at,
|
||||
is_all_day,
|
||||
duration,
|
||||
is_recurring,
|
||||
recurrence_pattern,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
current_timestamp() as _dbt_ran_at
|
||||
|
||||
FROM announcements_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__announcements
|
||||
@@ -0,0 +1,61 @@
|
||||
-- IMPORTS
|
||||
WITH bank_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'bank_logs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
bank_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
bank_logs.id,
|
||||
bank_logs.bank_id,
|
||||
bank_logs.company_id,
|
||||
bank_logs.reference,
|
||||
bank_logs.bank_name,
|
||||
bank_logs.holder_name,
|
||||
bank_logs.account_no,
|
||||
bank_logs.bank_branch,
|
||||
bank_logs.swift AS swift_code,
|
||||
bank_logs.snap AS cnaps_code,
|
||||
bank_logs.type AS bank_type,
|
||||
bank_logs.default AS is_default,
|
||||
bank_logs.status,
|
||||
bank_logs.country_id,
|
||||
bank_logs.deleted_at,
|
||||
bank_logs.created_at,
|
||||
bank_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM bank_logs
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__bank_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
bank_id,
|
||||
company_id,
|
||||
reference,
|
||||
bank_name,
|
||||
holder_name,
|
||||
account_no,
|
||||
bank_branch,
|
||||
swift_code,
|
||||
cnaps_code,
|
||||
bank_type,
|
||||
is_default,
|
||||
status,
|
||||
country_id,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM bank_logs_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__bank_logs
|
||||
@@ -0,0 +1,58 @@
|
||||
-- IMPORTS
|
||||
WITH banks AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'banks') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
banks_rename AS (
|
||||
|
||||
SELECT
|
||||
banks.id,
|
||||
banks.company_id,
|
||||
banks.reference,
|
||||
banks.bank_name,
|
||||
banks.holder_name,
|
||||
banks.account_no,
|
||||
banks.bank_branch,
|
||||
banks.swift AS swift_code,
|
||||
banks.snap AS cnaps_code,
|
||||
banks.type AS bank_type,
|
||||
banks.default AS is_default,
|
||||
banks.status,
|
||||
banks.country_id,
|
||||
banks.deleted_at,
|
||||
banks.created_at,
|
||||
banks.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM banks
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__banks AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
reference,
|
||||
bank_name,
|
||||
holder_name,
|
||||
account_no,
|
||||
bank_branch,
|
||||
swift_code,
|
||||
cnaps_code,
|
||||
bank_type,
|
||||
is_default,
|
||||
status,
|
||||
country_id,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM banks_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__banks
|
||||
@@ -0,0 +1,55 @@
|
||||
-- IMPORTS
|
||||
WITH booking_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'booking_logs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
booking_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
booking_logs.id,
|
||||
booking_logs.booking_id,
|
||||
booking_logs.company_id,
|
||||
booking_logs.marking AS marking_id,
|
||||
booking_logs.service_id AS service_type,
|
||||
booking_logs.bank_id,
|
||||
booking_logs.fix_amount AS fix_value,
|
||||
booking_logs.fix_currency_id,
|
||||
booking_logs.convertible_currency_id AS quote_currency_id,
|
||||
booking_logs.conversion_currency_id AS base_currency_id,
|
||||
booking_logs.status,
|
||||
booking_logs.deleted_at,
|
||||
booking_logs.created_at,
|
||||
booking_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM booking_logs
|
||||
|
||||
),
|
||||
|
||||
-- FINAL
|
||||
final_base_exchange__booking_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
booking_id,
|
||||
company_id,
|
||||
marking_id,
|
||||
service_type,
|
||||
bank_id,
|
||||
fix_value,
|
||||
fix_currency_id,
|
||||
quote_currency_id,
|
||||
base_currency_id,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM booking_logs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final_base_exchange__booking_logs
|
||||
@@ -0,0 +1,53 @@
|
||||
-- IMPORTS
|
||||
WITH bookings AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'bookings') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
bookings_rename AS (
|
||||
|
||||
SELECT
|
||||
bookings.id,
|
||||
bookings.company_id,
|
||||
bookings.marking AS marking_id,
|
||||
bookings.service_id AS service_type,
|
||||
bookings.bank_id,
|
||||
bookings.fix_amount AS fix_value,
|
||||
bookings.fix_currency_id,
|
||||
bookings.convertible_currency_id AS quote_currency_id,
|
||||
bookings.conversion_currency_id AS base_currency_id,
|
||||
bookings.status,
|
||||
bookings.deleted_at,
|
||||
bookings.created_at,
|
||||
bookings.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM bookings
|
||||
|
||||
),
|
||||
|
||||
-- FINAL
|
||||
final_base_exchange__bookings AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
marking_id,
|
||||
service_type,
|
||||
bank_id,
|
||||
fix_value,
|
||||
fix_currency_id,
|
||||
quote_currency_id,
|
||||
base_currency_id,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM bookings_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final_base_exchange__bookings
|
||||
@@ -0,0 +1,47 @@
|
||||
-- IMPORTS
|
||||
WITH companies AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'companies') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
companies_rename AS (
|
||||
|
||||
SELECT
|
||||
companies.id,
|
||||
companies.name,
|
||||
companies.reference AS marking_id,
|
||||
companies.debtor AS account_software_id,
|
||||
companies.type AS company_type,
|
||||
companies.business_type,
|
||||
companies.status,
|
||||
companies.deleted_at,
|
||||
companies.created_at,
|
||||
companies.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM companies
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__companies AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
marking_id,
|
||||
account_software_id,
|
||||
company_type,
|
||||
business_type,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM companies_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__companies
|
||||
@@ -0,0 +1,48 @@
|
||||
-- IMPORTS
|
||||
WITH contacts AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'contacts') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
companies_rename AS (
|
||||
|
||||
SELECT
|
||||
contacts.id,
|
||||
contacts.company_id,
|
||||
contacts.country_id,
|
||||
contacts.reference,
|
||||
contacts.phone,
|
||||
contacts.email,
|
||||
contacts.wechat_id,
|
||||
contacts.deleted_at,
|
||||
contacts.created_at,
|
||||
contacts.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM contacts
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__contacts AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
country_id,
|
||||
reference,
|
||||
phone,
|
||||
email,
|
||||
wechat_id,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM companies_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__contacts
|
||||
@@ -0,0 +1,41 @@
|
||||
-- IMPORTS
|
||||
WITH countries AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'countries') }}
|
||||
),
|
||||
|
||||
-- LOGIC
|
||||
countries_rename AS (
|
||||
|
||||
SELECT
|
||||
countries.id,
|
||||
countries.name,
|
||||
countries.short_code,
|
||||
countries.phone_code,
|
||||
countries.deleted_at,
|
||||
countries.created_at,
|
||||
countries.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM countries
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__countries AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
short_code,
|
||||
phone_code,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM countries_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__countries
|
||||
@@ -0,0 +1,43 @@
|
||||
-- IMPORTS
|
||||
WITH currencies AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'currencies') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
currencies_rename AS (
|
||||
|
||||
SELECT
|
||||
currencies.id,
|
||||
currencies.country_id,
|
||||
currencies.name,
|
||||
currencies.short_code,
|
||||
currencies.symbol,
|
||||
currencies.deleted_at,
|
||||
currencies.created_at,
|
||||
currencies.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM currencies
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__currencies AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
country_id,
|
||||
name,
|
||||
short_code,
|
||||
symbol,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM currencies_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__currencies
|
||||
@@ -0,0 +1,39 @@
|
||||
-- IMPORTS
|
||||
WITH currency_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'currency_logs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
currency_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
currency_logs.id,
|
||||
currency_logs.currency_id,
|
||||
currency_logs.created_by,
|
||||
currency_logs.deleted_at,
|
||||
currency_logs.created_at,
|
||||
currency_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM currency_logs
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__currency_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
currency_id,
|
||||
created_by,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM currency_logs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__currency_logs
|
||||
@@ -0,0 +1,50 @@
|
||||
-- IMPORTS
|
||||
WITH currency_rate_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'currency_rate_logs') }}
|
||||
),
|
||||
-- LOGIC
|
||||
currency_rate_logs_clean_list AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
round(1/selling, 5) AS selling
|
||||
FROM
|
||||
currency_rate_logs
|
||||
WHERE
|
||||
id IN ('579','580','581','582')
|
||||
),
|
||||
|
||||
currency_rate_logs_rename_clean_wrong_rate AS (
|
||||
|
||||
SELECT
|
||||
currency_rate_logs.id,
|
||||
currency_rate_logs.currency_rate_id,
|
||||
COALESCE(currency_rate_logs_clean_list.selling, currency_rate_logs.selling) AS base_to_quote_currency_exchange_rate,
|
||||
currency_rate_logs.created_by,
|
||||
currency_rate_logs.created_at,
|
||||
currency_rate_logs.updated_at,
|
||||
CURRENT_TIMESTAMP() AS _dbt_ran_at
|
||||
|
||||
FROM currency_rate_logs
|
||||
|
||||
LEFT JOIN currency_rate_logs_clean_list
|
||||
ON (currency_rate_logs.id = currency_rate_logs_clean_list.id)
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__currency_rate_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
currency_rate_id,
|
||||
base_to_quote_currency_exchange_rate,
|
||||
created_by,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM currency_rate_logs_rename_clean_wrong_rate
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__currency_rate_logs
|
||||
@@ -0,0 +1,43 @@
|
||||
-- IMPORTS
|
||||
WITH currency_rates AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'currency_rates') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
currency_rates_rename AS (
|
||||
|
||||
SELECT
|
||||
currency_rates.id,
|
||||
currency_rates.currency_id AS quote_currency_id,
|
||||
currency_rates.selling AS base_to_quote_currency_exchange_rate,
|
||||
currency_rates.payment_method_type AS payment_method,
|
||||
currency_rates.service_id AS service_type,
|
||||
currency_rates.deleted_at,
|
||||
currency_rates.created_at,
|
||||
currency_rates.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM currency_rates
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__currency_rates AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
quote_currency_id,
|
||||
base_to_quote_currency_exchange_rate,
|
||||
payment_method,
|
||||
service_type,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM currency_rates_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__currency_rates
|
||||
@@ -0,0 +1,44 @@
|
||||
-- IMPORTS
|
||||
WITH districts AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'districts') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
districts_rename AS (
|
||||
|
||||
SELECT
|
||||
districts.id,
|
||||
districts.country_id,
|
||||
districts.state_id,
|
||||
districts.name,
|
||||
districts.postcode,
|
||||
districts.status,
|
||||
districts.deleted_at,
|
||||
districts.created_at,
|
||||
districts.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM districts
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__districts AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
country_id,
|
||||
state_id,
|
||||
name,
|
||||
postcode,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM districts_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__districts
|
||||
@@ -0,0 +1,53 @@
|
||||
-- IMPORTS
|
||||
WITH documents AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'documents') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
documents_rename AS (
|
||||
|
||||
SELECT
|
||||
documents.id,
|
||||
documents.owner_type,
|
||||
documents.owner_id,
|
||||
documents.document_type,
|
||||
documents.reference,
|
||||
documents.status,
|
||||
documents.issued_date AS issued_at,
|
||||
documents.expired_date AS expired_at,
|
||||
documents.approver AS approved_by,
|
||||
documents.approval_date AS approved_at,
|
||||
documents.deleted_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM documents
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__documents AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
owner_type,
|
||||
owner_id,
|
||||
document_type,
|
||||
reference,
|
||||
status,
|
||||
issued_at,
|
||||
expired_at,
|
||||
approved_by,
|
||||
approved_at,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM documents_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__documents
|
||||
@@ -0,0 +1,32 @@
|
||||
-- IMPORTS
|
||||
WITH employees AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'employees') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
employees_rename AS (
|
||||
|
||||
SELECT
|
||||
employees.company_id,
|
||||
employees.user_id,
|
||||
employees.status,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM employees
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__employees AS (
|
||||
|
||||
SELECT
|
||||
company_id,
|
||||
user_id,
|
||||
status,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM employees_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__employees
|
||||
@@ -0,0 +1,40 @@
|
||||
-- IMPORTS
|
||||
WITH failed_jobs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'failed_jobs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
failed_jobs_rename AS (
|
||||
|
||||
SELECT
|
||||
failed_jobs.id,
|
||||
failed_jobs.connection,
|
||||
failed_jobs.queue,
|
||||
failed_jobs.payload,
|
||||
failed_jobs.exception,
|
||||
failed_jobs.failed_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM failed_jobs
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__stg_failed_jobs__exchange AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
connection,
|
||||
queue,
|
||||
payload,
|
||||
exception,
|
||||
failed_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM failed_jobs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__stg_failed_jobs__exchange
|
||||
@@ -0,0 +1,42 @@
|
||||
-- IMPORTS
|
||||
WITH files AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'files') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
files_rename AS (
|
||||
|
||||
SELECT
|
||||
files.id,
|
||||
files.document_id,
|
||||
files.file,
|
||||
files.file_type,
|
||||
files.deleted_at,
|
||||
files.created_at,
|
||||
files.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM files
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__files AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
document_id,
|
||||
file,
|
||||
file_type,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM files_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__files
|
||||
@@ -0,0 +1,34 @@
|
||||
-- IMPORTS
|
||||
WITH group_transactions AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'group_transactions') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
group_transactions_rename AS (
|
||||
|
||||
SELECT
|
||||
group_transactions.id,
|
||||
group_transactions.group_id,
|
||||
group_transactions.transaction_id,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM group_transactions
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__group_transactions AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
group_id,
|
||||
transaction_id,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM group_transactions_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__group_transactions
|
||||
@@ -0,0 +1,55 @@
|
||||
-- IMPORTS
|
||||
WITH groups AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'groups') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
groups_rename AS (
|
||||
|
||||
SELECT
|
||||
groups.id,
|
||||
groups.reference AS marking_id,
|
||||
groups.issuer AS issued_by,
|
||||
groups.receiver AS received_by,
|
||||
groups.amount AS base_amount,
|
||||
groups.original_amount AS quote_amount,
|
||||
groups.currency_id AS base_currency_id,
|
||||
groups.original_currency_id AS quote_currency_id,
|
||||
groups.currency_rate AS base_to_quote_currency_exchange_rate,
|
||||
groups.tax AS base_tax,
|
||||
groups.service_charge AS base_service_charge,
|
||||
groups.status,
|
||||
groups.created_at,
|
||||
groups.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM groups
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__groups AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
marking_id,
|
||||
issued_by,
|
||||
received_by,
|
||||
base_amount,
|
||||
quote_amount,
|
||||
base_currency_id,
|
||||
quote_currency_id,
|
||||
base_to_quote_currency_exchange_rate,
|
||||
base_tax,
|
||||
base_service_charge,
|
||||
status,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM groups_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__groups
|
||||
@@ -0,0 +1,41 @@
|
||||
-- IMPORTS
|
||||
WITH jobs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'jobs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
jobs_rename AS (
|
||||
|
||||
SELECT
|
||||
jobs.id,
|
||||
jobs.queue,
|
||||
jobs.payload,
|
||||
jobs.attempts,
|
||||
TO_TIMESTAMP(jobs.reserved_at) AS reserved_at,
|
||||
TO_TIMESTAMP(jobs.available_at) AS available_at,
|
||||
TO_TIMESTAMP(jobs.created_at) AS created_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM jobs
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__jobs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
queue,
|
||||
payload,
|
||||
attempts,
|
||||
reserved_at,
|
||||
available_at,
|
||||
created_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM jobs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__jobs
|
||||
@@ -0,0 +1,33 @@
|
||||
-- IMPORTS
|
||||
WITH migrations AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'migrations') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
migrations_rename AS (
|
||||
|
||||
SELECT
|
||||
migrations.id,
|
||||
migrations.migration,
|
||||
migrations.batch,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM migrations
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__migrations AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
migration,
|
||||
batch,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM migrations_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__migrations
|
||||
@@ -0,0 +1,34 @@
|
||||
-- IMPORTS
|
||||
WITH model_has_roles AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'model_has_roles') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
migrations_rename AS (
|
||||
|
||||
SELECT
|
||||
model_has_roles.role_id,
|
||||
model_has_roles.model_type,
|
||||
model_has_roles.model_id,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM model_has_roles
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__model_has_roles AS (
|
||||
|
||||
SELECT
|
||||
role_id,
|
||||
model_type,
|
||||
model_id,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM migrations_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__model_has_roles
|
||||
@@ -0,0 +1,53 @@
|
||||
-- IMPORTS
|
||||
WITH notifications AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'notifications') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
notifications_rename AS (
|
||||
|
||||
SELECT
|
||||
notifications.id,
|
||||
notifications.title,
|
||||
notifications.description,
|
||||
notifications.subject_type,
|
||||
notifications.subject_id,
|
||||
notifications.target_type,
|
||||
notifications.target_id,
|
||||
notifications.causer_type,
|
||||
notifications.causer_id,
|
||||
notifications.status,
|
||||
notifications.deleted_at,
|
||||
notifications.created_at,
|
||||
notifications.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM notifications
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__notifications AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
subject_type,
|
||||
subject_id,
|
||||
target_type,
|
||||
target_id,
|
||||
causer_type,
|
||||
causer_id,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM notifications_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__notifications
|
||||
@@ -0,0 +1,42 @@
|
||||
-- IMPORTS
|
||||
WITH password_resets AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'password_resets') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
password_resets_rename AS (
|
||||
|
||||
SELECT
|
||||
password_resets.id,
|
||||
password_resets.user_id,
|
||||
password_resets.token,
|
||||
password_resets.is_expired,
|
||||
password_resets.is_complete,
|
||||
password_resets.created_at,
|
||||
password_resets.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM password_resets
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__password_resets AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
token,
|
||||
is_expired,
|
||||
is_complete,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM password_resets_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__password_resets
|
||||
@@ -0,0 +1,38 @@
|
||||
-- IMPORTS
|
||||
WITH permissions AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'permissions') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
permissions_rename AS (
|
||||
|
||||
SELECT
|
||||
permissions.id,
|
||||
permissions.name,
|
||||
permissions.guard_name,
|
||||
permissions.created_at,
|
||||
permissions.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM permissions
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__permissions AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
guard_name,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM permissions_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__permissions
|
||||
@@ -0,0 +1,32 @@
|
||||
-- IMPORTS
|
||||
WITH role_has_permissions AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'role_has_permissions') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
role_has_permissions_rename AS (
|
||||
|
||||
SELECT
|
||||
role_has_permissions.permission_id,
|
||||
role_has_permissions.role_id,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM role_has_permissions
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__exchange_base__role_has_permissions AS (
|
||||
|
||||
SELECT
|
||||
permission_id,
|
||||
role_id,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM role_has_permissions_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__exchange_base__role_has_permissions
|
||||
@@ -0,0 +1,40 @@
|
||||
-- IMPORTS
|
||||
WITH roles AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'roles') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
roles_rename AS (
|
||||
|
||||
SELECT
|
||||
roles.id,
|
||||
roles.name,
|
||||
roles.guard_name,
|
||||
roles.type,
|
||||
roles.created_at,
|
||||
roles.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM roles
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__roles AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
guard_name,
|
||||
type,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM roles_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__roles
|
||||
@@ -0,0 +1,43 @@
|
||||
-- IMPORTS
|
||||
WITH segment_companies AS (
|
||||
SELECT * FROM {{ ref('snap_exchange__segment_companies') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
segment_companies_rename AS (
|
||||
|
||||
SELECT
|
||||
segment_companies.concat_id,
|
||||
segment_companies.segment_id,
|
||||
segment_companies.company_id,
|
||||
segment_companies.deleted_at,
|
||||
segment_companies.created_at,
|
||||
segment_companies.updated_at,
|
||||
segment_companies.dbt_valid_from,
|
||||
segment_companies.dbt_valid_to,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM segment_companies
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__segment_companies AS (
|
||||
|
||||
SELECT
|
||||
concat_id,
|
||||
segment_id,
|
||||
company_id,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
dbt_valid_from,
|
||||
dbt_valid_to,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM segment_companies_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__segment_companies
|
||||
@@ -0,0 +1,43 @@
|
||||
-- IMPORTS
|
||||
WITH segment_constants AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'segment_constants') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
segment_constants_rename AS (
|
||||
|
||||
SELECT
|
||||
segment_constants.id,
|
||||
segment_constants.segment_id,
|
||||
segment_constants.name,
|
||||
segment_constants.reference AS marking_id,
|
||||
segment_constants.detail,
|
||||
segment_constants.deleted_at,
|
||||
segment_constants.created_at,
|
||||
segment_constants.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM segment_constants
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final_base_exchange__segment_constants AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
segment_id,
|
||||
name,
|
||||
marking_id,
|
||||
detail,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM segment_constants_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final_base_exchange__segment_constants
|
||||
@@ -0,0 +1,40 @@
|
||||
-- IMPORTS
|
||||
WITH segments AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'segments') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
segments_rename AS (
|
||||
|
||||
SELECT
|
||||
segments.id,
|
||||
segments.name,
|
||||
segments.type,
|
||||
segments.status,
|
||||
segments.deleted_at,
|
||||
segments.created_at,
|
||||
segments.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM segments
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__segments AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM segments_rename
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__segments
|
||||
@@ -0,0 +1,39 @@
|
||||
-- IMPORTS
|
||||
WITH service_types AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'service_types') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
service_types_rename AS (
|
||||
|
||||
SELECT
|
||||
service_types.id,
|
||||
service_types.name,
|
||||
service_types.status,
|
||||
service_types.deleted_at,
|
||||
service_types.created_at,
|
||||
service_types.updated_at,
|
||||
CURRENT_TIMESTAMP() AS _dbt_ran_at
|
||||
|
||||
FROM service_types
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__service_types AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM service_types_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__service_types
|
||||
@@ -0,0 +1,41 @@
|
||||
-- IMPORTS
|
||||
WITH states AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'states') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
states_rename AS (
|
||||
|
||||
SELECT
|
||||
states.id,
|
||||
states.country_id,
|
||||
states.name,
|
||||
states.status,
|
||||
states.deleted_at,
|
||||
states.created_at,
|
||||
states.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM states
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__states AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
country_id,
|
||||
name,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM states_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__states
|
||||
@@ -0,0 +1,48 @@
|
||||
-- IMPORTS
|
||||
WITH transaction_details AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'transaction_detail') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
transaction_details_rename AS (
|
||||
|
||||
SELECT
|
||||
transaction_details.id,
|
||||
transaction_details.transaction_id,
|
||||
transaction_details.product_code,
|
||||
transaction_details.product_name,
|
||||
transaction_details.quantity,
|
||||
transaction_details.price,
|
||||
transaction_details.amount,
|
||||
transaction_details.deleted_at,
|
||||
transaction_details.created_at,
|
||||
transaction_details.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM transaction_details
|
||||
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__transaction_details AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
transaction_id,
|
||||
product_code,
|
||||
product_name,
|
||||
quantity,
|
||||
price,
|
||||
amount,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM transaction_details_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__transaction_details
|
||||
@@ -0,0 +1,73 @@
|
||||
-- IMPORTS
|
||||
WITH transaction_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'transaction_logs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
transaction_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
transaction_logs.id,
|
||||
transaction_logs.transaction_id,
|
||||
transaction_logs.owner_type,
|
||||
transaction_logs.owner_id,
|
||||
transaction_logs.type AS transaction_type,
|
||||
transaction_logs.issuer AS issued_by,
|
||||
transaction_logs.receiver AS received_by,
|
||||
transaction_logs.recipient_bank_account_id,
|
||||
transaction_logs.payment_method,
|
||||
transaction_logs.payment_reference,
|
||||
transaction_logs.bill_no,
|
||||
transaction_logs.amount AS base_value,
|
||||
transaction_logs.original_amount AS quote_value,
|
||||
transaction_logs.currency_id AS base_currency_id,
|
||||
transaction_logs.original_currency_id AS quote_currency_id,
|
||||
transaction_logs.currency_rate AS base_to_quote_currency_exchange_rate,
|
||||
transaction_logs.tax AS base_tax,
|
||||
transaction_logs.service_charge AS base_service_charge,
|
||||
transaction_logs.expires_on AS expired_at,
|
||||
transaction_logs.status,
|
||||
transaction_logs.deleted_at,
|
||||
transaction_logs.created_at,
|
||||
transaction_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM transaction_logs
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__transaction_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
transaction_id,
|
||||
owner_type,
|
||||
owner_id,
|
||||
transaction_type,
|
||||
issued_by,
|
||||
received_by,
|
||||
recipient_bank_account_id,
|
||||
payment_method,
|
||||
payment_reference,
|
||||
bill_no,
|
||||
base_value,
|
||||
quote_value,
|
||||
base_currency_id,
|
||||
quote_currency_id,
|
||||
base_to_quote_currency_exchange_rate,
|
||||
base_tax,
|
||||
base_service_charge,
|
||||
expired_at,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM transaction_logs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__transaction_logs
|
||||
@@ -0,0 +1,71 @@
|
||||
-- IMPORTS
|
||||
WITH transactions AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'transactions') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
transactions_rename AS (
|
||||
|
||||
SELECT
|
||||
transactions.id,
|
||||
transactions.owner_type,
|
||||
transactions.owner_id,
|
||||
transactions.type AS transaction_type,
|
||||
transactions.issuer AS issued_by,
|
||||
transactions.receiver AS received_by,
|
||||
transactions.recipient_bank_account_id,
|
||||
transactions.payment_method,
|
||||
transactions.payment_reference,
|
||||
transactions.bill_no,
|
||||
transactions.amount AS base_value,
|
||||
transactions.original_amount AS quote_value,
|
||||
transactions.currency_id AS base_currency_id,
|
||||
transactions.original_currency_id AS quote_currency_id,
|
||||
transactions.currency_rate AS base_to_quote_currency_exchange_rate,
|
||||
transactions.tax AS base_tax,
|
||||
transactions.service_charge AS base_service_charge,
|
||||
transactions.expires_on AS expired_at,
|
||||
transactions.status,
|
||||
transactions.deleted_at,
|
||||
transactions.created_at,
|
||||
transactions.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM transactions
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__transactions AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
owner_type,
|
||||
owner_id,
|
||||
transaction_type,
|
||||
issued_by,
|
||||
received_by,
|
||||
recipient_bank_account_id,
|
||||
payment_method,
|
||||
payment_reference,
|
||||
bill_no,
|
||||
base_value,
|
||||
quote_value,
|
||||
base_currency_id,
|
||||
quote_currency_id,
|
||||
base_to_quote_currency_exchange_rate,
|
||||
base_tax,
|
||||
base_service_charge,
|
||||
expired_at,
|
||||
status,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM transactions_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__transactions
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
-- IMPORTS
|
||||
WITH user_email_verifications AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'user_email_verifications') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
user_email_verifications_rename AS (
|
||||
|
||||
SELECT
|
||||
user_email_verifications.id,
|
||||
user_email_verifications.email,
|
||||
user_email_verifications.token,
|
||||
user_email_verifications.is_complete AS is_completed,
|
||||
user_email_verifications.is_active AS is_activated,
|
||||
user_email_verifications.is_sent,
|
||||
user_email_verifications.created_at,
|
||||
user_email_verifications.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM user_email_verifications
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__user_email_verifications AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
email,
|
||||
token,
|
||||
is_completed,
|
||||
is_activated,
|
||||
is_sent,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM user_email_verifications_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__user_email_verifications
|
||||
@@ -0,0 +1,47 @@
|
||||
-- IMPORTS
|
||||
WITH users AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'users') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
users_rename AS (
|
||||
|
||||
SELECT
|
||||
users.id,
|
||||
users.name,
|
||||
users.email,
|
||||
users.type AS user_type,
|
||||
users.status,
|
||||
users.remember_token,
|
||||
users.active_at,
|
||||
users.deleted_at,
|
||||
users.created_at,
|
||||
users.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM users
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__users AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
email,
|
||||
user_type,
|
||||
status,
|
||||
remember_token,
|
||||
active_at,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM users_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__users
|
||||
@@ -0,0 +1,47 @@
|
||||
-- IMPORTS
|
||||
WITH wallet_logs AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'wallet_logs') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
wallet_logs_rename AS (
|
||||
|
||||
SELECT
|
||||
wallet_logs.id,
|
||||
wallet_logs.wallet_id,
|
||||
wallet_logs.owner_type,
|
||||
wallet_logs.owner_id,
|
||||
wallet_logs.code,
|
||||
wallet_logs.currency_id,
|
||||
wallet_logs.amount,
|
||||
wallet_logs.deleted_at,
|
||||
wallet_logs.created_at,
|
||||
wallet_logs.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM wallet_logs
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__wallet_logs AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
wallet_id,
|
||||
owner_type,
|
||||
owner_id,
|
||||
code,
|
||||
currency_id,
|
||||
amount,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM wallet_logs_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__wallet_logs
|
||||
@@ -0,0 +1,45 @@
|
||||
-- IMPORTS
|
||||
WITH wallets AS (
|
||||
SELECT * FROM {{ source('src_exchange_mysql', 'wallets') }}
|
||||
),
|
||||
|
||||
|
||||
-- LOGIC
|
||||
wallets_rename AS (
|
||||
|
||||
SELECT
|
||||
wallets.id,
|
||||
wallets.owner_type,
|
||||
wallets.owner_id,
|
||||
wallets.code,
|
||||
wallets.currency_id,
|
||||
wallets.amount,
|
||||
wallets.deleted_at,
|
||||
wallets.created_at,
|
||||
wallets.updated_at,
|
||||
current_timestamp() AS _dbt_ran_at
|
||||
|
||||
FROM wallets
|
||||
),
|
||||
|
||||
|
||||
-- FINAL
|
||||
final__base_exchange__wallets AS (
|
||||
|
||||
SELECT
|
||||
id,
|
||||
owner_type,
|
||||
owner_id,
|
||||
code,
|
||||
currency_id,
|
||||
amount,
|
||||
deleted_at,
|
||||
created_at,
|
||||
updated_at,
|
||||
_dbt_ran_at
|
||||
|
||||
FROM wallets_rename
|
||||
|
||||
)
|
||||
|
||||
SELECT * FROM final__base_exchange__wallets
|
||||
Reference in New Issue
Block a user