@@ -9,13 +9,13 @@ use std::{
99 task:: { Context , Poll } ,
1010} ;
1111
12+ use crate :: schema:: SchemaOrCustom ;
1213use crate :: {
1314 db:: {
1415 core_extension:: CoreExtensionVersion , pool:: LeasedConnection , streams:: SyncStreamTracker ,
1516 } ,
1617 env:: PowerSyncEnvironment ,
1718 error:: PowerSyncError ,
18- schema:: Schema ,
1919 sync:: { MAX_OP_ID , coordinator:: SyncCoordinator , status:: SyncStatus , status:: SyncStatusData } ,
2020 util:: SharedFuture ,
2121} ;
@@ -28,7 +28,7 @@ pub struct InnerPowerSyncState {
2828 /// The schema passed to the database.
2929 ///
3030 /// This is forwarded to the sync client for raw tables.
31- pub schema : Arc < Schema > ,
31+ pub schema : Arc < SchemaOrCustom > ,
3232 /// A container for the current sync status.
3333 pub status : SyncStatus ,
3434 /// A collection of currently-referenced sync stream subscriptions.
@@ -41,7 +41,11 @@ pub struct InnerPowerSyncState {
4141}
4242
4343impl InnerPowerSyncState {
44- pub fn new ( env : PowerSyncEnvironment , schema : Schema , sync : & Arc < SyncCoordinator > ) -> Self {
44+ pub fn new (
45+ env : PowerSyncEnvironment ,
46+ schema : SchemaOrCustom ,
47+ sync : & Arc < SyncCoordinator > ,
48+ ) -> Self {
4549 Self {
4650 env,
4751 did_initialize : SharedFuture :: new ( ) ,
@@ -73,7 +77,9 @@ impl InnerPowerSyncState {
7377 }
7478
7579 fn update_schema_internal ( & self , conn : & Connection ) -> Result < ( ) , PowerSyncError > {
76- self . schema . validate ( ) ?;
80+ if let SchemaOrCustom :: Schema ( schema) = self . schema . as_ref ( ) {
81+ schema. validate ( ) ?;
82+ } ;
7783
7884 let serialized_schema = serde_json:: to_string ( & self . schema ) ?;
7985 conn. prepare ( "SELECT powersync_replace_schema(?)" ) ?
0 commit comments