-- Shadow DB
DROP database IF EXISTS ${usagestatsPermanentDBSchema} CASCADE;
CREATE database ${usagestatsPermanentDBSchema};

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.views_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.views_stats
AS SELECT * FROM ${usageStatsDB}.views_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.pageviews_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.pageviews_stats
AS SELECT * FROM ${usageStatsDB}.pageviews_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.downloads_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.downloads_stats
AS SELECT * FROM ${usageStatsDB}.downloads_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.usage_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.usage_stats
AS SELECT * FROM ${usageStatsDB}.usage_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.project_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.project_stats
AS SELECT * FROM ${usageStatsDB}.project_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.datasource_stats;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.datasource_stats
AS SELECT * FROM ${usageStatsDB}.datasource_stats;

DROP VIEW IF EXISTS ${usagestatsPermanentDBSchema}.counter_r5_stats_with_metrics;

CREATE VIEW IF NOT EXISTS ${usagestatsPermanentDBSchema}.counter_r5_stats_with_metrics
AS SELECT * FROM ${usageStatsDB}.tbl_all_r5_metrics;

