# Moose / Migrate / Migration Types Documentation – TypeScript ## Included Files 1. moose/migrate/migration-types/migration-types.mdx ## Migration Examples & Advanced Development Source: moose/migrate/migration-types/migration-types.mdx Detailed migration examples and advanced development topics # Migration Types This guide provides detailed examples of different migration types. For the complete workflow overview, see [Migrations & Planning](/moose/migrate/planning). ## Adding New Infrastructure Components Keep in mind that only the modules that you have enabled in your `moose.config.toml` will be included in your migrations. ```toml file="moose.config.toml" [features] olap = true streaming_engine = true workflows = true ``` ### New OLAP Table or Materialized View ```ts file="app/index.ts" interface AnalyticsSchema { id: string; event_type: string; timestamp: Date; user_id: string; value: number; } /apply-migrations`} ctaLabel="Learn More"> Check out the OLAP migrations guide to learn more about the different migration modes. ### New Stream ```ts file="app/index.ts" interface UserSchema { id: string; name: string; email: string; age: number; created_at: Date; is_active: boolean; } ``` **Migration Result:** Adds `age`, `created_at`, and `is_active` columns to existing table ### Removing Fields ```ts file="app/index.ts" // Before interface UserSchema { id: string; name: string; email: string; age: number; deprecated_field: string; // Will be removed } // After interface UserSchema { id: string; name: string; email: string; age: number; } ``` **Migration Result:** Drops `deprecated_field` column (data permanently lost) ### Type Changes ```ts file="app/index.ts" // Before interface UserSchema { id: string; name: string; email: string; score: number; // Will change to string } // After interface UserSchema { id: string; name: string; email: string; score: string; // Changed from number } ``` **Migration Result:** Alters `score` column type (data converted if compatible) ## Removing Infrastructure ```ts file="app/index.ts" // Before usersTable = new OlapTable("Users"); analyticsTable = new OlapTable("Analytics"); deprecatedTable = new OlapTable("Deprecated"); // After (remove deprecated table) usersTable = new OlapTable("Users"); analyticsTable = new OlapTable("Analytics"); ``` **Migration Result:** Drops `Deprecated` table (all data lost) ## Working with Local Infrastructure There are two main ways to inspect your local infrastructure to see how your migrations are applied: ### Using the CLI Run `moose ls` to see the current state of your infrastructure: ```bash # Verify object definitions moose ls ``` ### Connecting to your local infrastructure You can also connect directly to your local infrastructure to see the state of your infrastructure. All credentials for your local infrastructure are located in your project config file (`moose.config.toml`). #### Connecting to ClickHouse ```bash # Using clickhouse-client clickhouse-client --host localhost --port 18123 --user panda --password pandapass --database local # Using connection string clickhouse-client "clickhouse://panda:pandapass@localhost:18123/local" ``` #### Connecting to Redpanda ```bash # Using kafka-console-consumer kafka-console-consumer --bootstrap-server localhost:19092 --topic UserEvents --from-beginning # Using kafka-console-producer kafka-console-producer --bootstrap-server localhost:19092 --topic UserEvents ``` #### Viewing Temporal Workflows Navigate to `http://localhost:8080` to view the Temporal UI and see registered workflows. ## Gotchas: Your dev server must be running to connect to your local infrastructure. ```bash moose dev ``` Only the modules that you have enabled in your `moose.config.toml` will be included in your migrations: ```toml file="moose.config.toml" [features] olap = true # Required for OLAP Tables and Materialized Views streaming_engine = true # Required for Streams workflows = true # Required for Workflows and Tasks ```