Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions projects/demo/models/staging/decidim/elections/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

sources:
- name: decidim
database: "{{ env_var('DBNAME') }}"
schema: public
tables:
- name: decidim_elections_elections
- name: decidim_elections_questions
- name: decidim_elections_response_options
- name: decidim_elections_voters
- name: decidim_elections_votes
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_elections_elections'
) %}

{% if relation is not none %}
SELECT
id,
decidim_component_id,
title,
description,
announcement,
start_at,
end_at,
results_availability,
published_at,
deleted_at,
created_at,
updated_at,
census_manifest,
census_settings,
published_results_at,
votes_count,
FROM {{ source('decidim', 'decidim_elections_elections') }}
{% else %}
SELECT
CAST(NULL AS BIGINT) AS id,
CAST(NULL AS BIGINT) AS decidim_component_id,
CAST(NULL AS JSONB) AS title,
CAST(NULL AS JSONB) AS description,
CAST(NULL AS JSONB) AS announcement,
CAST(NULL AS TIMESTAMP) AS start_at,
CAST(NULL AS TIMESTAMP) AS end_at,
CAST(NULL AS TEXT) AS results_availability,
CAST(NULL AS TIMESTAMP) AS published_at,
CAST(NULL AS TIMESTAMP) AS deleted_at,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at,
CAST(NULL AS TEXT) AS census_manifest,
CAST(NULL AS JSONB) AS census_settings,
CAST(NULL AS TIMESTAMP) AS published_results_at,
CAST(NULL AS BIGINT) AS votes_count
LIMIT 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_elections_questions'
) %}

{% if relation is not none %}
SELECT
id,
election_id,
body,
description,
mandatory,
question_type,
multiple_option,
position,
created_at,
updated_at,
published_results_at,
voting_enabled_at,
votes_count,
response_options_count
FROM {{ source('decidim', 'decidim_elections_questions') }}
{% else %}
SELECT
CAST(NULL AS BIGINT) AS id,
CAST(NULL AS BIGINT) AS election_id,
CAST(NULL AS JSONB) AS body,
CAST(NULL AS JSONB) AS description,
CAST(NULL AS BOOLEAN) AS mandatory,
CAST(NULL AS TEXT) AS question_type,
CAST(NULL AS BIGINT) AS position,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at,
CAST(NULL AS TIMESTAMP) AS published_results_at,
CAST(NULL AS TIMESTAMP) AS voting_enabled_at,
CAST(NULL AS BIGINT) AS votes_count,
CAST(NULL AS BIGINT) AS response_options_count
LIMIT 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_elections_response_options'
) %}

{% if relation is not none %}
SELECT
id,
question_id,
body,
created_at,
updated_at,
votes_count
FROM {{ source('decidim', 'decidim_elections_response_options') }}
{% else %}
SELECT
CAST(NULL AS BIGINT) AS id,
CAST(NULL AS BIGINT) AS question_id,
CAST(NULL AS JSONB) AS body,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at,
CAST(NULL AS BIGINT) AS votes_count
LIMIT 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_elections_voters'
) %}

{% if relation is not none %}
SELECT
id,
election_id,
data,
created_at,
updated_at
FROM {{ source('decidim', 'decidim_elections_voters') }}
{% else %}
SELECT
CAST(NULL AS BIGINT) AS id,
CAST(NULL AS BIGINT) AS election_id,
CAST(NULL AS JSONB) AS data,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at
LIMIT 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_elections_votes'
) %}

{% if relation is not none %}
SELECT
id,
question_id,
response_option_id,
voter_uid,
created_at,
updated_at
FROM {{ source('decidim', 'decidim_elections_votes') }}
{% else %}
SELECT
CAST(NULL AS BIGINT) AS id,
CAST(NULL AS BIGINT) AS question_id,
CAST(NULL AS BIGINT) AS response_option_id,
CAST(NULL AS TEXT) AS voter_uid,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at
LIMIT 0
{% endif %}
Loading