-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
timestamp
, quota_used
, proposer
to blocks and add `timestam…
…p` to transactions
- Loading branch information
1 parent
69ce3d5
commit 02e1b38
Showing
6 changed files
with
42 additions
and
10 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
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,13 @@ | ||
class AddSomeInfoToBlocks < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :blocks, :timestamp, :bigint | ||
add_column :blocks, :proposer, :string | ||
add_column :blocks, :quota_used, :decimal, precision: 100 | ||
|
||
reversible do |dir| | ||
dir.up do | ||
execute "UPDATE blocks SET timestamp = subquery.timestamp::bigint, proposer = subquery.proposer::varchar, quota_used = subquery.quota_used::decimal(100) FROM (SELECT (b.header ->> 'timestamp') AS timestamp, (b.header ->> 'proposer') AS proposer, ('x'||lpad(substr((b.header ->> 'quotaUsed'), 3, char_length(b.header ->> 'quotaUsed')), 16, '0'))::bit(64)::bigint AS quota_used, block_hash FROM blocks AS b) AS subquery WHERE subquery.block_hash = blocks.block_hash;" | ||
end | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20181229030703_add_timestamp_to_transactions.rb
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,11 @@ | ||
class AddTimestampToTransactions < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :transactions, :timestamp, :bigint | ||
|
||
reversible do |dir| | ||
dir.up do | ||
execute %{UPDATE transactions AS tx SET "timestamp" = subquery.timestamp FROM (SELECT block_hash, "timestamp" FROM blocks AS b) AS subquery WHERE tx.block_hash = subquery.block_hash;} | ||
end | ||
end | ||
end | ||
end |
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