1
- use std:: { fmt:: Write , sync:: Arc , time:: Instant } ;
1
+ use std:: { collections :: HashMap , fmt:: Write , sync:: Arc , time:: Instant } ;
2
2
3
3
use diesel:: {
4
4
connection:: SimpleConnection ,
@@ -24,7 +24,10 @@ use crate::{
24
24
relational:: { Table , VID_COLUMN } ,
25
25
} ;
26
26
27
- use super :: { Catalog , Layout , Namespace } ;
27
+ use super :: {
28
+ index:: { load_indexes_from_table, IndexList } ,
29
+ Catalog , Layout , Namespace ,
30
+ } ;
28
31
29
32
// Additions to `Table` that are useful for pruning
30
33
impl Table {
@@ -94,9 +97,15 @@ impl TablePair {
94
97
if catalog:: table_exists ( conn, dst_nsp. as_str ( ) , & dst. name ) ? {
95
98
writeln ! ( query, "truncate table {};" , dst. qualified_name) ?;
96
99
} else {
100
+ let mut list = IndexList {
101
+ indexes : HashMap :: new ( ) ,
102
+ } ;
103
+ let indexes = load_indexes_from_table ( conn, & src, dst_nsp. as_str ( ) ) ?;
104
+ list. indexes . insert ( src. name . to_string ( ) , indexes) ;
105
+
97
106
// In case of pruning we don't do delayed creation of indexes,
98
107
// as the asumption is that there is not that much data inserted.
99
- dst. as_ddl ( schema, catalog, None , & mut query) ?;
108
+ dst. as_ddl ( schema, catalog, Some ( & list ) , & mut query) ?;
100
109
}
101
110
conn. batch_execute ( & query) ?;
102
111
0 commit comments