|
| 1 | +use sea_orm_migration::prelude::*; |
| 2 | + |
| 3 | +#[derive(DeriveMigrationName)] |
| 4 | +pub struct Migration; |
| 5 | + |
| 6 | +#[async_trait::async_trait] |
| 7 | +impl MigrationTrait for Migration { |
| 8 | + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { |
| 9 | + let db = manager.get_connection(); |
| 10 | + |
| 11 | + db.execute_unprepared("ANALYZE;").await?; |
| 12 | + db.execute_unprepared("DELETE FROM sqlite_stat1;").await?; |
| 13 | + db.execute_unprepared( |
| 14 | + r#" |
| 15 | + INSERT INTO sqlite_stat1(tbl, idx, stat) VALUES |
| 16 | + ('block_signature', 'idx_block_signature_block_hash', '96134 1'), |
| 17 | + ('block_signature', 'sqlite_autoindex_block_signature_1', '96134 1'), |
| 18 | + ('metadata', 'sqlite_autoindex_metadata_1', '4 1'), |
| 19 | + ('l2_block', 'idx_batch_index', '14240240 120'), |
| 20 | + ('l2_block', 'idx_batch_hash', '14240240 120'), |
| 21 | + ('l2_block', 'idx_block_hash', '14240240 1'), |
| 22 | + ('l2_block', 'idx_l2_block_block_number', '14240240 1'), |
| 23 | + ('block_data', 'sqlite_autoindex_block_data_1', '8484488 1'), |
| 24 | + ('l1_message', 'idx_l1_message_queue_index', '1079892 1'), |
| 25 | + ('l1_message', 'idx_l1_message_l2_block', '1079892 8'), |
| 26 | + ('l1_message', 'idx_l1_block_number', '1079892 3'), |
| 27 | + ('l1_message', 'idx_l1_message_hash', '1079892 1'), |
| 28 | + ('l1_message', 'idx_queue_hash', '1079892 61'), |
| 29 | + ('batch_commit', 'idx_finalized_block_number', '118854 2'), |
| 30 | + ('batch_commit', 'idx_batch_commit_block_number', '118854 2'), |
| 31 | + ('batch_commit', 'idx_batch_commit_hash', '118854 1'), |
| 32 | + ('batch_commit', 'sqlite_autoindex_batch_commit_1', '118854 1'), |
| 33 | + ('seaql_migrations', 'sqlite_autoindex_seaql_migrations_1', '17 1'); |
| 34 | + "#, |
| 35 | + ) |
| 36 | + .await?; |
| 37 | + db.execute_unprepared("ANALYZE sqlite_schema;").await?; |
| 38 | + |
| 39 | + Ok(()) |
| 40 | + } |
| 41 | + |
| 42 | + async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { |
| 43 | + Ok(()) |
| 44 | + } |
| 45 | +} |
0 commit comments