Skip to content

Commit 0c36351

Browse files
authored
Auto-migrate: Allow adding new variants at the tail (#2874)
1 parent 47fd168 commit 0c36351

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1335
-386
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bench/benches/delete_table.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use rand::{prelude::*, seq::SliceRandom};
99
use smallvec::SmallVec;
1010
use spacetimedb::db::datastore::locking_tx_datastore::delete_table;
1111
use spacetimedb_data_structures::map::HashSet;
12-
use spacetimedb_table::indexes::{PageIndex, PageOffset, RowPointer, Size, SquashedOffset};
12+
use spacetimedb_sats::layout::Size;
13+
use spacetimedb_table::indexes::{PageIndex, PageOffset, RowPointer, SquashedOffset};
1314
use std::collections::BTreeSet;
1415

1516
fn time<R>(body: impl FnOnce() -> R) -> Duration {

crates/bench/benches/index.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use criterion::{
77
use foldhash::{HashSet, HashSetExt};
88
use itertools::Itertools as _;
99
use spacetimedb_data_structures::map::{Entry, HashMap};
10-
use spacetimedb_table::indexes::{PageIndex, PageOffset, RowPointer, Size, SquashedOffset};
10+
use spacetimedb_sats::layout::Size;
11+
use spacetimedb_table::indexes::{PageIndex, PageOffset, RowPointer, SquashedOffset};
1112
use spacetimedb_table::table_index::unique_direct_index::UniqueDirectIndex;
1213
use spacetimedb_table::table_index::uniquemap::UniqueMap;
1314

crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ spacetimedb
117117
│ │ │ └── keccak
118118
│ │ ├── smallvec
119119
│ │ ├── spacetimedb_bindings_macro (*)
120+
│ │ ├── spacetimedb_data_structures (*)
120121
│ │ ├── spacetimedb_primitives (*)
121122
│ │ └── thiserror (*)
122123
│ └── thiserror (*)

crates/codegen/src/csharp.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use crate::util::{
1212
type_ref_name,
1313
};
1414
use convert_case::{Case, Casing};
15+
use spacetimedb_lib::sats::layout::PrimitiveType;
1516
use spacetimedb_primitives::ColId;
1617
use spacetimedb_schema::def::{BTreeAlgorithm, IndexAlgorithm, ModuleDef, TableDef, TypeDef};
1718
use spacetimedb_schema::identifier::Identifier;
1819
use spacetimedb_schema::schema::{Schema, TableSchema};
1920
use spacetimedb_schema::type_for_generate::{
20-
AlgebraicTypeDef, AlgebraicTypeUse, PlainEnumTypeDef, PrimitiveType, ProductTypeDef, SumTypeDef,
21-
TypespaceForGenerate,
21+
AlgebraicTypeDef, AlgebraicTypeUse, PlainEnumTypeDef, ProductTypeDef, SumTypeDef, TypespaceForGenerate,
2222
};
2323

2424
const INDENT: &str = " ";
@@ -187,7 +187,7 @@ const REDUCER_EVENTS: &str = r#"
187187
return Event;
188188
}
189189
}
190-
190+
191191
/// <summary>
192192
/// Access to tables in the client cache, which stores a read-only replica of the remote database state.
193193
///
@@ -368,11 +368,11 @@ const REDUCER_EVENTS: &str = r#"
368368
369369
/// <summary>
370370
/// Subscribe to the following SQL queries.
371-
///
371+
///
372372
/// This method returns immediately, with the data not yet added to the DbConnection.
373373
/// The provided callbacks will be invoked once the data is returned from the remote server.
374374
/// Data from all the provided queries will be returned at the same time.
375-
///
375+
///
376376
/// See the SpacetimeDB SQL docs for more information on SQL syntax:
377377
/// <a href="https://spacetimedb.com/docs/sql">https://spacetimedb.com/docs/sql</a>
378378
/// </summary>

crates/codegen/src/rust.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use super::util::{collect_case, iter_reducers, print_lines, type_ref_name};
33
use super::Lang;
44
use crate::util::{iter_tables, iter_types, iter_unique_cols, print_auto_generated_file_comment};
55
use convert_case::{Case, Casing};
6+
use spacetimedb_lib::sats::layout::PrimitiveType;
67
use spacetimedb_lib::sats::AlgebraicTypeRef;
78
use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, TypeDef};
89
use spacetimedb_schema::identifier::Identifier;
910
use spacetimedb_schema::schema::{Schema, TableSchema};
10-
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse, PrimitiveType};
11+
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse};
1112
use std::collections::BTreeSet;
1213
use std::fmt::{self, Write};
1314
use std::ops::Deref;

crates/codegen/src/typescript.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ use std::fmt::{self, Write};
88
use std::ops::Deref;
99

1010
use convert_case::{Case, Casing};
11+
use spacetimedb_lib::sats::layout::PrimitiveType;
1112
use spacetimedb_lib::sats::AlgebraicTypeRef;
1213
use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, TypeDef};
1314
use spacetimedb_schema::identifier::Identifier;
1415
use spacetimedb_schema::schema::{Schema, TableSchema};
15-
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse, PrimitiveType};
16+
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse};
1617

1718
use super::code_indenter::{CodeIndenter, Indenter};
1819
use super::Lang;

crates/codegen/src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
use super::code_indenter::Indenter;
99
use convert_case::{Case, Casing};
1010
use itertools::Itertools;
11+
use spacetimedb_lib::sats::layout::PrimitiveType;
1112
use spacetimedb_lib::version;
1213
use spacetimedb_lib::{db::raw_def::v9::Lifecycle, sats::AlgebraicTypeRef};
1314
use spacetimedb_primitives::ColList;
@@ -20,7 +21,7 @@ use spacetimedb_schema::{
2021
use spacetimedb_schema::{
2122
def::{ModuleDef, ReducerDef},
2223
identifier::Identifier,
23-
type_for_generate::{AlgebraicTypeUse, PrimitiveType},
24+
type_for_generate::AlgebraicTypeUse,
2425
};
2526

2627
/// Turns a closure `f: Fn(&mut Formatter) -> Result` into `fmt::Display`.

crates/codegen/tests/snapshots/codegen__codegen_csharp.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/cli/tests/codegen.rs
2+
source: crates/codegen/tests/codegen.rs
33
expression: outfiles
44
---
55
"Reducers/Add.g.cs" = '''
@@ -1215,7 +1215,7 @@ namespace SpacetimeDB
12151215
return Event;
12161216
}
12171217
}
1218-
1218+
12191219
/// <summary>
12201220
/// Access to tables in the client cache, which stores a read-only replica of the remote database state.
12211221
///
@@ -1396,11 +1396,11 @@ namespace SpacetimeDB
13961396

13971397
/// <summary>
13981398
/// Subscribe to the following SQL queries.
1399-
///
1399+
///
14001400
/// This method returns immediately, with the data not yet added to the DbConnection.
14011401
/// The provided callbacks will be invoked once the data is returned from the remote server.
14021402
/// Data from all the provided queries will be returned at the same time.
1403-
///
1403+
///
14041404
/// See the SpacetimeDB SQL docs for more information on SQL syntax:
14051405
/// <a href="https://spacetimedb.com/docs/sql">https://spacetimedb.com/docs/sql</a>
14061406
/// </summary>

crates/core/src/db/datastore/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ pub enum TableError {
8282
Duplicate(#[from] table::DuplicateError),
8383
#[error(transparent)]
8484
ReadColTypeError(#[from] read_column::TypeError),
85+
#[error(transparent)]
86+
ChangeColumnsError(#[from] table::ChangeColumnsError),
8587
}
8688

8789
#[derive(Error, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)