@@ -41,6 +41,7 @@ class RegistryModifier
4141 protected const STRING_COLUMN = AbstractColumn::STRING ;
4242 protected const BIG_INTEGER_COLUMN = 'bigInteger ' ;
4343 protected const DATETIME_COLUMN = 'datetime ' ;
44+ protected const SNOWFLAKE_COLUMN = 'snowflake ' ;
4445 protected const ULID_COLUMN = 'ulid ' ;
4546 protected const UUID_COLUMN = 'uuid ' ;
4647
@@ -85,6 +86,13 @@ public static function isStringType(string $type): bool
8586 return $ matches ['type ' ] === 'string ' ;
8687 }
8788
89+ public static function isSnowflakeType (string $ type ): bool
90+ {
91+ \preg_match (self ::DEFINITION , $ type , $ matches );
92+
93+ return $ matches ['type ' ] === self ::SNOWFLAKE_COLUMN ;
94+ }
95+
8896 public static function isUlidType (string $ type ): bool
8997 {
9098 \preg_match (self ::DEFINITION , $ type , $ matches );
@@ -188,6 +196,31 @@ public function addStringColumn(string $columnName, string $fieldName, int|null
188196 }
189197
190198 /**
199+ * @param non-empty-string $columnName
200+ * @throws BehaviorCompilationException
201+ */
202+ public function addSnowflakeColumn (string $ columnName , string $ fieldName , int |null $ generated = null ): AbstractColumn
203+ {
204+ if ($ this ->fields ->has ($ fieldName )) {
205+ if (!static ::isSnowflakeType ($ this ->fields ->get ($ fieldName )->getType ())) {
206+ throw new BehaviorCompilationException (
207+ \sprintf ('Field %s must be of type %s. ' , $ fieldName , self ::SNOWFLAKE_COLUMN ),
208+ );
209+ }
210+ $ this ->validateColumnName ($ fieldName , $ columnName );
211+ $ this ->fields ->get ($ fieldName )->setGenerated ($ generated );
212+
213+ return $ this ->table ->column ($ columnName );
214+ }
215+
216+ $ field = (new Field ())->setColumn ($ columnName )->setType (self ::SNOWFLAKE_COLUMN )->setGenerated ($ generated );
217+ $ this ->fields ->set ($ fieldName , $ field );
218+
219+ return $ this ->table ->column ($ columnName )->type (self ::SNOWFLAKE_COLUMN );
220+ }
221+
222+ /**
223+ * @param non-empty-string $columnName
191224 * @throws BehaviorCompilationException
192225 */
193226 public function addUlidColumn (string $ columnName , string $ fieldName , int |null $ generated = null ): AbstractColumn
@@ -211,6 +244,7 @@ public function addUlidColumn(string $columnName, string $fieldName, int|null $g
211244 }
212245
213246 /**
247+ * @param non-empty-string $columnName
214248 * @throws BehaviorCompilationException
215249 */
216250 public function addUuidColumn (string $ columnName , string $ fieldName , int |null $ generated = null ): AbstractColumn
0 commit comments