-
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.
Update table import in table-initialization.ts
- Loading branch information
1 parent
ebfd095
commit 776116e
Showing
5 changed files
with
39 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
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,22 @@ | ||
-- view -- | ||
CREATE MATERIALIZED VIEW IF NOT EXISTS blocks_mv | ||
ENGINE = MergeTree | ||
ORDER BY (chain, timestamp, block_number) | ||
AS SELECT | ||
block_id, | ||
block_number, | ||
chain, | ||
timestamp | ||
FROM blocks; | ||
|
||
-- DROP TABLE IF EXISTS blocks_mv; | ||
|
||
-- OPTIMIZE TABLE blocks_mv FINAL; | ||
|
||
-- -- insert -- | ||
-- INSERT INTO blocks_mv SELECT | ||
-- block_id, | ||
-- block_number, | ||
-- chain, | ||
-- timestamp | ||
-- FROM blocks; |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
import { join } from "path"; | ||
|
||
function file(path: string) { | ||
return Bun.file(join(import.meta.dirname, path)).text(); | ||
} | ||
|
||
const glob = new Bun.Glob("**/*.sql"); | ||
const tables: [string, string][] = []; | ||
|
||
for (const path of glob.scanSync(import.meta.dirname)) { | ||
tables.push([path.replace(".sql", ""), await file(path)]) | ||
} | ||
|
||
export default tables; |