You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
349 B
18 lines
349 B
6 years ago
|
|
||
|
# --- !Ups
|
||
|
|
||
|
CREATE TABLE aggregated_amounts(
|
||
|
name TEXT NOT NULL,
|
||
|
value AMOUNT_TYPE NOT NULL,
|
||
|
-- constraints
|
||
|
CONSTRAINT aggregated_amounts_name_pk PRIMARY KEY (name)
|
||
|
);
|
||
|
|
||
|
INSERT INTO aggregated_amounts
|
||
|
SELECT 'available_coins' AS name, COALESCE(SUM(received - spent), 0) AS value FROM balances;
|
||
|
|
||
|
|
||
|
# --- !Downs
|
||
|
|
||
|
DROP TABLE aggregated_amounts;
|