-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from rarimo/feat/genesis-multiusage-referrals
Now we can use flag genesis=true to specify that only one referral mu…
- Loading branch information
Showing
9 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- +migrate Up | ||
ALTER TABLE referrals | ||
RENAME COLUMN is_consumed TO usage_left; | ||
|
||
ALTER TABLE referrals ALTER COLUMN usage_left DROP DEFAULT; | ||
|
||
ALTER TABLE referrals | ||
ALTER usage_left TYPE INTEGER | ||
USING | ||
CASE | ||
WHEN usage_left=TRUE THEN 0 | ||
ELSE 1 | ||
END; | ||
|
||
ALTER TABLE referrals ALTER COLUMN usage_left SET DEFAULT 1; | ||
|
||
ALTER TABLE balances DROP CONSTRAINT balances_referred_by_key; | ||
|
||
-- +migrate Down | ||
ALTER TABLE referrals ALTER COLUMN usage_left DROP DEFAULT; | ||
|
||
ALTER TABLE referrals | ||
ALTER usage_left TYPE BOOLEAN | ||
USING | ||
CASE | ||
WHEN usage_left > 0 THEN FALSE | ||
ELSE TRUE | ||
END; | ||
|
||
ALTER TABLE referrals | ||
RENAME COLUMN usage_left TO is_consumed; | ||
|
||
ALTER TABLE referrals ALTER COLUMN is_consumed SET DEFAULT FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters