Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

test(schema/oracle): replace the migration round-trip with recorded goldens (#21344)

Danny Xu45e9da75b6e9
diff --git a/backend/plugin/schema/oracle/generate_migration_testcontainer_test.go b/backend/plugin/schema/oracle/generate_migration_cases_test.go
similarity index 86%
rename from backend/plugin/schema/oracle/generate_migration_testcontainer_test.go
rename to backend/plugin/schema/oracle/generate_migration_cases_test.go
index 600d528787..256d6dd794 100644
--- a/backend/plugin/schema/oracle/generate_migration_testcontainer_test.go
+++ b/backend/plugin/schema/oracle/generate_migration_cases_test.go
@@ -1,48 +1,19 @@
package oracle
-import (
- "context"
- "fmt"
- "slices"
- "strings"
- "testing"
-
- "github.com/google/go-cmp/cmp"
- "github.com/google/uuid"
- "github.com/stretchr/testify/require"
- "google.golang.org/protobuf/testing/protocmp"
-
- "github.com/bytebase/bytebase/backend/common/testcontainer"
- storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/plugin/schema"
- "github.com/bytebase/bytebase/backend/store/model"
-)
-
-// TestGenerateMigrationWithTestcontainer tests the generate migration function
-// by applying migrations and rollback to verify the schema can be restored.
-//
-//nolint:tparallel
-func TestGenerateMigrationWithTestcontainer(t *testing.T) {
- if testing.Short() {
- t.Skip("Skipping Oracle testcontainer test in short mode")
- }
-
- ctx := context.Background()
-
- // Get Oracle container from testcontainer utility
- container := testcontainer.GetTestOracleContainer(ctx, t)
- t.Cleanup(func() { container.Close(ctx) })
-
- // Get SYSTEM database connection for user management
- systemDB := container.GetDB()
+// generateMigrationCase is one schema-change fixture: apply initialSchema to an
+// empty schema, then apply migrationDDL, and the generator must produce the DDL
+// that takes the second state back to the first.
+type generateMigrationCase struct {
+ name string
+ initialSchema string
+ migrationDDL string
+ description string
+}
- // Test cases with various schema changes
- testCases := []struct {
- name string
- initialSchema string
- migrationDDL string
- description string
- }{
+// generateMigrationCases returns the fixtures shared by the golden test and the
+// container-backed recorder that captures their metadata.
+func generateMigrationCases() []generateMigrationCase {
+ return []generateMigrationCase{
{
name: "create_tables_with_fk",
initialSchema: `
@@ -1710,230 +1681,4 @@ COMMENT ON TABLE SPECIAL_DATA IS '';
description: "Reverse: Remove all comments with special characters",
},
}
-
- // Oracle Free in CI slows down heavily when too many schema-heavy
- // subtests execute concurrently against the same container.
- const maxConcurrentSubtests = 4
- parallelGate := make(chan struct{}, maxConcurrentSubtests)
-
- for _, tc := range testCases {
- tc := tc // Capture range variable
- t.Run(tc.name, func(t *testing.T) {
- t.Parallel()
- parallelGate <- struct{}{}
- defer func() {
- <-parallelGate
- }()
-
- // Create unique Oracle user for this test (Oracle users are schemas)
- // Use UUID to ensure uniqueness and avoid name collisions
- testUser := fmt.Sprintf("U_%s", strings.ReplaceAll(uuid.New().String(), "-", "_"))
-
- // Create user using shared SYSTEM connection
- require.NoError(t, createOracleUser(systemDB, testUser))
-
- // Connect as the test user
- driver, err := createOracleDriver(ctx, container.GetHost(), container.GetPort(), testUser)
- require.NoError(t, err)
- defer driver.Close(ctx)
-
- // Execute initial schema
- if err := executeStatements(ctx, driver, tc.initialSchema); err != nil {
- t.Fatalf("Failed to execute initial schema: %v", err)
- }
-
- // Get schema metadata A
- schemaA, err := driver.SyncDBSchema(ctx)
- require.NoError(t, err)
-
- // Step 2: Do some migration and get schema result B
- if err := executeStatements(ctx, driver, tc.migrationDDL); err != nil {
- t.Fatalf("Failed to execute migration DDL: %v", err)
- }
-
- // Get schema metadata B
- schemaB, err := driver.SyncDBSchema(ctx)
- require.NoError(t, err)
-
- // Step 3: Call generate migration to get the rollback DDL
- // Convert to model.DatabaseSchema
- dbMetadataA := model.NewDatabaseMetadata(schemaA, nil, nil, storepb.Engine_ORACLE, false)
- dbMetadataB := model.NewDatabaseMetadata(schemaB, nil, nil, storepb.Engine_ORACLE, false)
-
- // Get diff from B to A (to generate rollback)
- diff, err := schema.GetDatabaseSchemaDiff(storepb.Engine_ORACLE, dbMetadataB, dbMetadataA)
- require.NoError(t, err)
-
- // Generate rollback migration
- rollbackDDL, err := schema.GenerateMigration(storepb.Engine_ORACLE, diff)
- require.NoError(t, err)
-
- // Step 4: Run rollback DDL and get schema result C
- if err := executeStatements(ctx, driver, rollbackDDL); err != nil {
- t.Fatalf("Failed to execute rollback DDL: %v", err)
- }
-
- // Get schema metadata C
- schemaC, err := driver.SyncDBSchema(ctx)
- require.NoError(t, err)
-
- // Step 5: Compare schema result A and C to ensure they are the same
- normalizeMetadataForComparison(schemaA)
- normalizeMetadataForComparison(schemaC)
-
- // Normalize column positions to 0 before comparison to ignore position differences
- normalizeColumnPositions(schemaA)
- normalizeColumnPositions(schemaC)
-
- // Use cmp with protocmp for proto message comparison
- if diff := cmp.Diff(schemaA, schemaC, protocmp.Transform()); diff != "" {
- t.Errorf("Schema mismatch after rollback (-want +got):\n%s", diff)
- }
- })
- }
-}
-
-// normalizeMetadataForComparison normalizes metadata to ignore differences that don't affect schema equality
-func normalizeMetadataForComparison(metadata *storepb.DatabaseSchemaMetadata) {
- // Clear database name as it might differ
- metadata.Name = ""
-
- // Normalize schemas
- for _, schema := range metadata.Schemas {
- // Normalize tables
- for _, table := range schema.Tables {
- table.DataSize = 0
- table.IndexSize = 0
- table.RowCount = 0
-
- // Filter out system-generated indexes that reference virtual columns
- var filteredIndexes []*storepb.IndexMetadata
- for _, idx := range table.Indexes {
- // Skip indexes that reference system-generated virtual columns
- hasVirtualColumn := false
- for _, expr := range idx.Expressions {
- if strings.HasPrefix(expr, "SYS_NC") {
- hasVirtualColumn = true
- break
- }
- }
- if !hasVirtualColumn {
- filteredIndexes = append(filteredIndexes, idx)
- }
- }
- table.Indexes = filteredIndexes
-
- // Sort columns by name for consistent comparison
- sortColumnsByName(table.Columns)
-
- // Sort indexes by name
- sortIndexesByName(table.Indexes)
-
- // Sort foreign keys by name
- sortForeignKeysByName(table.ForeignKeys)
-
- // Sort check constraints by name
- sortCheckConstraintsByName(table.CheckConstraints)
- }
-
- // Filter out system-generated sequences
- var filteredSequences []*storepb.SequenceMetadata
- for _, seq := range schema.Sequences {
- if !strings.HasPrefix(seq.Name, "ISEQ$$_") {
- filteredSequences = append(filteredSequences, seq)
- }
- }
- schema.Sequences = filteredSequences
-
- // Sort all collections for consistent comparison
- sortTablesByName(schema.Tables)
- sortViewsByName(schema.Views)
- sortMaterializedViewsByName(schema.MaterializedViews)
- sortFunctionsByName(schema.Functions)
- sortSequencesByName(schema.Sequences)
- }
-
- // Sort schemas by name
- sortSchemasByName(metadata.Schemas)
-
- // Sort extensions by name
- sortExtensionsByName(metadata.Extensions)
-}
-
-// Sorting helper functions
-func sortSchemasByName(schemas []*storepb.SchemaMetadata) {
- slices.SortFunc(schemas, func(a, b *storepb.SchemaMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortTablesByName(tables []*storepb.TableMetadata) {
- slices.SortFunc(tables, func(a, b *storepb.TableMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortColumnsByName(columns []*storepb.ColumnMetadata) {
- slices.SortFunc(columns, func(a, b *storepb.ColumnMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortIndexesByName(indexes []*storepb.IndexMetadata) {
- slices.SortFunc(indexes, func(a, b *storepb.IndexMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortForeignKeysByName(fks []*storepb.ForeignKeyMetadata) {
- slices.SortFunc(fks, func(a, b *storepb.ForeignKeyMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortCheckConstraintsByName(checks []*storepb.CheckConstraintMetadata) {
- slices.SortFunc(checks, func(a, b *storepb.CheckConstraintMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-// normalizeColumnPositions sets all column positions to 0 to ignore position differences during comparison
-func normalizeColumnPositions(metadata *storepb.DatabaseSchemaMetadata) {
- for _, schema := range metadata.Schemas {
- for _, table := range schema.Tables {
- for _, column := range table.Columns {
- column.Position = 0
- }
- }
- }
-}
-
-func sortViewsByName(views []*storepb.ViewMetadata) {
- slices.SortFunc(views, func(a, b *storepb.ViewMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortMaterializedViewsByName(mvs []*storepb.MaterializedViewMetadata) {
- slices.SortFunc(mvs, func(a, b *storepb.MaterializedViewMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortFunctionsByName(functions []*storepb.FunctionMetadata) {
- slices.SortFunc(functions, func(a, b *storepb.FunctionMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortSequencesByName(sequences []*storepb.SequenceMetadata) {
- slices.SortFunc(sequences, func(a, b *storepb.SequenceMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
-}
-
-func sortExtensionsByName(extensions []*storepb.ExtensionMetadata) {
- slices.SortFunc(extensions, func(a, b *storepb.ExtensionMetadata) int {
- return strings.Compare(a.Name, b.Name)
- })
}
diff --git a/backend/plugin/schema/oracle/generate_migration_fixture_test.go b/backend/plugin/schema/oracle/generate_migration_fixture_test.go
new file mode 100644
index 0000000000..ba84e45a3d
--- /dev/null
+++ b/backend/plugin/schema/oracle/generate_migration_fixture_test.go
@@ -0,0 +1,50 @@
+package oracle
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/bytebase/bytebase/backend/common"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+)
+
+const generateMigrationFixtureDir = "testdata/generate_migration"
+
+// generateMigrationFixture is one case's pair of engine-reported schemas: the
+// state after initialSchema, and the state after migrationDDL. Both are
+// protojson because storepb messages do not round-trip through encoding/json.
+type generateMigrationFixture struct {
+ SchemaA json.RawMessage `json:"schemaA"`
+ SchemaB json.RawMessage `json:"schemaB"`
+}
+
+func generateMigrationFixturePath(name string) string {
+ return filepath.Join(generateMigrationFixtureDir, name+".json")
+}
+
+func generateMigrationGoldenPath(name string) string {
+ return filepath.Join(generateMigrationFixtureDir, name+".sql")
+}
+
+// loadGenerateMigrationFixture reads the metadata Oracle reported for a case.
+func loadGenerateMigrationFixture(t *testing.T, name string) (*storepb.DatabaseSchemaMetadata, *storepb.DatabaseSchemaMetadata) {
+ t.Helper()
+
+ path := generateMigrationFixturePath(name)
+ raw, err := os.ReadFile(path)
+ require.NoErrorf(t, err, "missing fixture %s; regenerate with: go test -tags oracle_record -run TestRecordGenerateMigrationFixtures ./backend/plugin/schema/oracle/", path)
+
+ var fixture generateMigrationFixture
+ require.NoError(t, json.Unmarshal(raw, &fixture), "failed to read %s", path)
+
+ schemaA := &storepb.DatabaseSchemaMetadata{}
+ require.NoError(t, common.ProtojsonUnmarshaler.Unmarshal(fixture.SchemaA, schemaA), "failed to decode schemaA in %s", path)
+ schemaB := &storepb.DatabaseSchemaMetadata{}
+ require.NoError(t, common.ProtojsonUnmarshaler.Unmarshal(fixture.SchemaB, schemaB), "failed to decode schemaB in %s", path)
+
+ return schemaA, schemaB
+}
diff --git a/backend/plugin/schema/oracle/generate_migration_record_test.go b/backend/plugin/schema/oracle/generate_migration_record_test.go
new file mode 100644
index 0000000000..f84d54b6c9
--- /dev/null
+++ b/backend/plugin/schema/oracle/generate_migration_record_test.go
@@ -0,0 +1,205 @@
+//go:build oracle_record
+
+// This file is the provenance of testdata/generate_migration/*.json: it applies
+// each fixture's DDL to a real Oracle, verifies the generated rollback against
+// that Oracle, and records what the engine reports, so the golden test can run
+// the generator against true synced metadata without a container. Refresh the
+// fixtures with:
+//
+// go test -tags oracle_record -count=1 -timeout 40m \
+// ./backend/plugin/schema/oracle/ -run TestRecordGenerateMigrationFixtures
+//
+// The live round trip the golden test cannot do lives here: generate the
+// rollback, execute it, and require that it restores the initial schema. A
+// generator that emits invalid or incomplete DDL fails the re-record instead of
+// silently blessing a new golden.
+//
+// Recorded metadata is what the engine reported, minus two adjustments that
+// would otherwise churn every fixture on re-record: table stats are zeroed, and
+// Oracle-allocated identifiers are canonicalized (see canonicalizeGeneratedNames).
+
+package oracle
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "os"
+ "regexp"
+ "strings"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/google/uuid"
+ "github.com/stretchr/testify/require"
+ "google.golang.org/protobuf/encoding/protojson"
+ "google.golang.org/protobuf/testing/protocmp"
+
+ "github.com/bytebase/bytebase/backend/common/testcontainer"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ "github.com/bytebase/bytebase/backend/plugin/db"
+ "github.com/bytebase/bytebase/backend/plugin/schema"
+ "github.com/bytebase/bytebase/backend/store/model"
+)
+
+// fixtureSchemaName replaces the throwaway Oracle user this recorder creates, so
+// a re-record does not churn every fixture with a new UUID-derived schema name.
+const fixtureSchemaName = "TESTSCHEMA"
+
+// oracleGeneratedName matches the identifiers Oracle allocates for itself:
+// identity-column sequences and the names it invents for unnamed constraints.
+// Both embed a database object number that depends on allocation order across
+// concurrently recording subtests, so the same schema recorded twice yields
+// different numbers.
+var oracleGeneratedName = regexp.MustCompile(`ISEQ\$\$_[0-9]+|SYS_C[0-9]+`)
+
+//nolint:tparallel
+func TestRecordGenerateMigrationFixtures(t *testing.T) {
+ ctx := context.Background()
+
+ container := testcontainer.GetTestOracleContainer(ctx, t)
+ t.Cleanup(func() { container.Close(ctx) })
+ systemDB := container.GetDB()
+
+ require.NoError(t, os.MkdirAll(generateMigrationFixtureDir, 0o755))
+
+ // Oracle Free slows down heavily when too many schema-heavy cases run
+ // concurrently against one container.
+ const maxConcurrent = 4
+ gate := make(chan struct{}, maxConcurrent)
+
+ for _, tc := range generateMigrationCases() {
+ t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+ gate <- struct{}{}
+ defer func() { <-gate }()
+
+ testUser := fmt.Sprintf("U_%s", strings.ReplaceAll(uuid.New().String(), "-", "_"))
+ require.NoError(t, createOracleUser(systemDB, testUser))
+
+ driver, err := createOracleDriver(ctx, container.GetHost(), container.GetPort(), testUser)
+ require.NoError(t, err)
+ defer driver.Close(ctx)
+
+ require.NoError(t, executeStatements(ctx, driver, tc.initialSchema), "failed to execute initial schema")
+ schemaA, err := driver.SyncDBSchema(ctx)
+ require.NoError(t, err)
+
+ require.NoError(t, executeStatements(ctx, driver, tc.migrationDDL), "failed to execute migration DDL")
+ schemaB, err := driver.SyncDBSchema(ctx)
+ require.NoError(t, err)
+
+ // Render the fixture before the round trip below mutates these
+ // messages, but write it only once Oracle has accepted the rollback.
+ fixture := renderFixture(t, schemaA, schemaB, testUser)
+
+ verifyRollbackAgainstOracle(ctx, t, driver, schemaA, schemaB)
+
+ out, err := json.MarshalIndent(fixture, "", " ")
+ require.NoError(t, err)
+ require.NoError(t, os.WriteFile(generateMigrationFixturePath(tc.name), append(out, '\n'), 0o644))
+ })
+ }
+}
+
+// verifyRollbackAgainstOracle is the live check the offline golden test cannot
+// make: generate the rollback from B back to A, execute it, and require that the
+// engine ends up where it started.
+func verifyRollbackAgainstOracle(ctx context.Context, t *testing.T, driver db.Driver, schemaA, schemaB *storepb.DatabaseSchemaMetadata) {
+ t.Helper()
+
+ dbSchemaA := model.NewDatabaseMetadata(schemaA, nil, nil, storepb.Engine_ORACLE, false)
+ dbSchemaB := model.NewDatabaseMetadata(schemaB, nil, nil, storepb.Engine_ORACLE, false)
+
+ diff, err := schema.GetDatabaseSchemaDiff(storepb.Engine_ORACLE, dbSchemaB, dbSchemaA)
+ require.NoError(t, err)
+
+ rollbackDDL, err := schema.GenerateMigration(storepb.Engine_ORACLE, diff)
+ require.NoError(t, err)
+
+ require.NoError(t, executeStatements(ctx, driver, rollbackDDL), "Oracle rejected the generated rollback:\n%s", rollbackDDL)
+
+ schemaC, err := driver.SyncDBSchema(ctx)
+ require.NoError(t, err)
+
+ normalizeMetadataForComparison(schemaA)
+ normalizeMetadataForComparison(schemaC)
+ normalizeColumnPositions(schemaA)
+ normalizeColumnPositions(schemaC)
+
+ if mismatch := cmp.Diff(schemaA, schemaC, protocmp.Transform()); mismatch != "" {
+ t.Errorf("rollback did not restore the initial schema (-want +got):\n%s\ngenerated DDL:\n%s", mismatch, rollbackDDL)
+ }
+}
+
+// renderFixture marshals the pair for storage. Both schemas go through one
+// canonicalization pass so an identifier Oracle allocated once carries the same
+// stable name on both sides.
+func renderFixture(t *testing.T, schemaA, schemaB *storepb.DatabaseSchemaMetadata, testUser string) generateMigrationFixture {
+ t.Helper()
+
+ rawA := marshalSchema(t, schemaA, testUser)
+ rawB := marshalSchema(t, schemaB, testUser)
+
+ canonical := canonicalizeGeneratedNames(rawA, rawB)
+ return generateMigrationFixture{
+ SchemaA: json.RawMessage(canonical[0]),
+ SchemaB: json.RawMessage(canonical[1]),
+ }
+}
+
+// marshalSchema renders one synced schema, substituting the throwaway user name.
+func marshalSchema(t *testing.T, metadata *storepb.DatabaseSchemaMetadata, testUser string) string {
+ t.Helper()
+
+ zeroVolatileStats(metadata)
+
+ raw, err := protojson.MarshalOptions{Multiline: true, Indent: " "}.Marshal(metadata)
+ require.NoError(t, err)
+
+ // The user name reaches the metadata as the database name and inside view,
+ // routine and constraint text, so substitute across the whole document.
+ return strings.ReplaceAll(string(raw), strings.ToUpper(testUser), fixtureSchemaName)
+}
+
+// canonicalizeGeneratedNames renumbers Oracle-allocated identifiers by order of
+// first appearance across the documents, so re-recording an unchanged schema
+// produces an unchanged fixture. Prefixes are preserved because the generator
+// keys on them: get_database_definition.go and generate_migration.go both test
+// for "ISEQ$$_" to recognize identity-column sequences.
+func canonicalizeGeneratedNames(docs ...string) []string {
+ canonical := make(map[string]string)
+ seen := make(map[string]int)
+
+ rename := func(match string) string {
+ if replacement, ok := canonical[match]; ok {
+ return replacement
+ }
+ prefix := "SYS_C"
+ if strings.HasPrefix(match, "ISEQ") {
+ prefix = "ISEQ$$_"
+ }
+ seen[prefix]++
+ replacement := fmt.Sprintf("%s%07d", prefix, seen[prefix])
+ canonical[match] = replacement
+ return replacement
+ }
+
+ out := make([]string, 0, len(docs))
+ for _, doc := range docs {
+ out = append(out, oracleGeneratedName.ReplaceAllStringFunc(doc, rename))
+ }
+ return out
+}
+
+// zeroVolatileStats clears the row and byte counts, which differ run to run and
+// are never read by the migration generator.
+func zeroVolatileStats(metadata *storepb.DatabaseSchemaMetadata) {
+ for _, schemaMetadata := range metadata.Schemas {
+ for _, table := range schemaMetadata.Tables {
+ table.DataSize = 0
+ table.IndexSize = 0
+ table.RowCount = 0
+ }
+ }
+}
diff --git a/backend/plugin/schema/oracle/generate_migration_test.go b/backend/plugin/schema/oracle/generate_migration_test.go
new file mode 100644
index 0000000000..739c385460
--- /dev/null
+++ b/backend/plugin/schema/oracle/generate_migration_test.go
@@ -0,0 +1,53 @@
+package oracle
+
+import (
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ "github.com/bytebase/bytebase/backend/plugin/schema"
+ "github.com/bytebase/bytebase/backend/store/model"
+)
+
+// TestGenerateMigration runs the rollback generator over metadata Oracle itself
+// reported for each fixture: diff the post-migration schema back to the initial
+// one and compare the DDL against the recorded golden. The metadata comes from
+// testdata/generate_migration/*.json, captured by TestRecordGenerateMigrationFixtures.
+//
+// Set record to regenerate the .sql goldens; it needs no Oracle. Refreshing the
+// .json metadata does, and is the recorder's job.
+func TestGenerateMigration(t *testing.T) {
+ t.Parallel()
+
+ const record = false
+
+ for _, tc := range generateMigrationCases() {
+ t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+
+ schemaA, schemaB := loadGenerateMigrationFixture(t, tc.name)
+
+ dbSchemaA := model.NewDatabaseMetadata(schemaA, nil, nil, storepb.Engine_ORACLE, false)
+ dbSchemaB := model.NewDatabaseMetadata(schemaB, nil, nil, storepb.Engine_ORACLE, false)
+
+ // Diff B back to A: the migration under test is the rollback.
+ diff, err := schema.GetDatabaseSchemaDiff(storepb.Engine_ORACLE, dbSchemaB, dbSchemaA)
+ require.NoError(t, err, "failed to diff %s", tc.description)
+
+ rollbackDDL, err := schema.GenerateMigration(storepb.Engine_ORACLE, diff)
+ require.NoError(t, err, "failed to generate migration for %s", tc.description)
+
+ goldenPath := generateMigrationGoldenPath(tc.name)
+ if record {
+ require.NoError(t, os.WriteFile(goldenPath, []byte(rollbackDDL), 0o644))
+ return
+ }
+
+ want, err := os.ReadFile(goldenPath)
+ require.NoErrorf(t, err, "missing golden %s; set record to regenerate", goldenPath)
+ require.Equal(t, string(want), rollbackDDL, "generated migration changed for %s", tc.description)
+ })
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.json
new file mode 100644
index 0000000000..153c50306e
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.json
@@ -0,0 +1,144 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 2,
+ "type": "DATE"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AMOUNT",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "REGION",
+ "position": 6,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 2,
+ "type": "DATE"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AMOUNT",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "REGION",
+ "position": 6,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "UK_SALES_DATE_CUSTOMER",
+ "expressions": [
+ "SALE_DATE",
+ "CUSTOMER_ID",
+ "PRODUCT_ID"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_SALES_MONTH_YEAR",
+ "expressions": [
+ "EXTRACT(YEAR FROM \"SALE_DATE\")",
+ "EXTRACT(MONTH FROM \"SALE_DATE\")"
+ ],
+ "descending": [
+ false,
+ false
+ ],
+ "type": "FUNCTION-BASED NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_SALES_REGION_AMOUNT",
+ "expressions": [
+ "\"REGION\"",
+ "\"AMOUNT\""
+ ],
+ "descending": [
+ false,
+ true
+ ],
+ "type": "FUNCTION-BASED NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHK_AMOUNT_RANGE",
+ "expression": "AMOUNT \u003e 0 AND AMOUNT \u003c= 999999.99"
+ },
+ {
+ "name": "CHK_REGION_VALID",
+ "expression": "REGION IN ('NORTH', 'SOUTH', 'EAST', 'WEST', 'CENTRAL')"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.sql
new file mode 100644
index 0000000000..c89f10bdc2
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/advanced_indexes_and_constraints.sql
@@ -0,0 +1,6 @@
+ALTER TABLE "SALES_DATA" DROP CONSTRAINT "CHK_AMOUNT_RANGE";
+ALTER TABLE "SALES_DATA" DROP CONSTRAINT "CHK_REGION_VALID";
+DROP INDEX "IDX_SALES_MONTH_YEAR";
+DROP INDEX "IDX_SALES_REGION_AMOUNT";
+ALTER TABLE "SALES_DATA" DROP CONSTRAINT "UK_SALES_DATE_CUSTOMER";
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.json b/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.json
new file mode 100644
index 0000000000..6389025076
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.json
@@ -0,0 +1,228 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(8,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(30 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 6,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(30 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 6,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "STOCK_QUANTITY",
+ "position": 8,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "WEIGHT",
+ "position": 9,
+ "nullable": true,
+ "type": "NUMBER(5,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CREATED_AT",
+ "expressions": [
+ "\"CREATED_AT\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_NAME_CATEGORY",
+ "expressions": [
+ "\"NAME\"",
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false,
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ },
+ {
+ "name": "CHECK_STOCK_NON_NEGATIVE",
+ "expression": "STOCK_QUANTITY \u003e= 0"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.sql b/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.sql
new file mode 100644
index 0000000000..90f02ad161
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/alter_table_columns.sql
@@ -0,0 +1,11 @@
+ALTER TABLE "PRODUCTS" DROP CONSTRAINT "CHECK_PRICE_POSITIVE";
+ALTER TABLE "PRODUCTS" DROP CONSTRAINT "CHECK_STOCK_NON_NEGATIVE";
+DROP INDEX "IDX_PRODUCTS_CREATED_AT";
+DROP INDEX "IDX_PRODUCTS_NAME_CATEGORY";
+ALTER TABLE "PRODUCTS" DROP COLUMN "CREATED_AT";
+ALTER TABLE "PRODUCTS" DROP COLUMN "STOCK_QUANTITY";
+ALTER TABLE "PRODUCTS" DROP COLUMN "WEIGHT";
+
+ALTER TABLE "PRODUCTS" MODIFY "NAME" VARCHAR2(50 BYTE);
+ALTER TABLE "PRODUCTS" MODIFY "PRICE" NUMBER(8,2);
+ALTER TABLE "PRODUCTS" MODIFY "DESCRIPTION" NULL;
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.json b/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.json
new file mode 100644
index 0000000000..7531b7f60a
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.json
@@ -0,0 +1,321 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_POSTS_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "COMMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "POST_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 5,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_COMMENT_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ },
+ {
+ "name": "FK_POST",
+ "columns": [
+ "POST_ID"
+ ],
+ "referencedTable": "POSTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_POSTS_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_TITLE_LENGTH",
+ "expression": "LENGTH(TITLE) \u003e 0"
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 5,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.sql b/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.sql
new file mode 100644
index 0000000000..86f5d03258
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/basic_table_operations.sql
@@ -0,0 +1,7 @@
+ALTER TABLE "COMMENTS" DROP CONSTRAINT "FK_COMMENT_USER";
+ALTER TABLE "COMMENTS" DROP CONSTRAINT "FK_POST";
+DROP TABLE "COMMENTS";
+ALTER TABLE "POSTS" DROP CONSTRAINT "CHECK_TITLE_LENGTH";
+DROP INDEX "IDX_USERS_EMAIL";
+ALTER TABLE "USERS" DROP COLUMN "IS_ACTIVE";
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.json b/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.json
new file mode 100644
index 0000000000..0c6752d343
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.json
@@ -0,0 +1,258 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PREFERRED_ORDER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 3,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PREFERRED_ORDER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PREFERRED_ORDER",
+ "columns": [
+ "PREFERRED_ORDER_ID"
+ ],
+ "referencedTable": "ORDERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 3,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_CUSTOMER",
+ "columns": [
+ "CUSTOMER_ID"
+ ],
+ "referencedTable": "CUSTOMERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ORDER_ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "UNIT_PRICE",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_ORDER_ITEM",
+ "columns": [
+ "ORDER_ID"
+ ],
+ "referencedTable": "ORDERS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ],
+ "triggers": [
+ {
+ "name": "TRG_UPDATE_ORDER_TOTAL",
+ "event": "INSERT OR UPDATE OR DELETE",
+ "timing": "AFTER EACH ROW",
+ "body": "CREATE OR REPLACE TRIGGER TRG_UPDATE_ORDER_TOTAL\nAFTER INSERT OR UPDATE OR DELETE ON ORDER_ITEMS\nFOR EACH ROW\nDECLARE\n V_ORDER_ID NUMBER;\n V_TOTAL NUMBER(10, 2);\nBEGIN\n -- Get order ID\n IF INSERTING OR UPDATING THEN\n V_ORDER_ID := :NEW.ORDER_ID;\n ELSE\n V_ORDER_ID := :OLD.ORDER_ID;\n END IF;\n \n -- Calculate new total\n SELECT NVL(SUM(QUANTITY * UNIT_PRICE), 0) INTO V_TOTAL\n FROM ORDER_ITEMS\n WHERE ORDER_ID = V_ORDER_ID;\n \n -- Update order total\n UPDATE ORDERS SET TOTAL_AMOUNT = V_TOTAL WHERE ID = V_ORDER_ID;\nEND;"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.sql b/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.sql
new file mode 100644
index 0000000000..a850463671
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/circular_foreign_key_dependencies.sql
@@ -0,0 +1,5 @@
+ALTER TABLE "CUSTOMERS" DROP CONSTRAINT "FK_PREFERRED_ORDER";
+ALTER TABLE "ORDERS" DROP CONSTRAINT "FK_CUSTOMER";
+ALTER TABLE "ORDER_ITEMS" DROP CONSTRAINT "FK_ORDER_ITEM";
+DROP TABLE "ORDER_ITEMS";
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.json b/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.json
new file mode 100644
index 0000000000..ddcdf139d4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.json
@@ -0,0 +1,331 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "MULTILANG_CONTENT",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE_EN",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TITLE_ES",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TITLE_ZH",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT_TEXT",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TAGS",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(1000 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "SPECIAL_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "DATA_VALUE",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(500 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "METADATA_JSON",
+ "position": 3,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "UNICODE_TEXT",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "BINARY_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "BLOB"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "COMPLEX_TYPES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "XML_DATA",
+ "position": 2,
+ "nullable": true,
+ "type": "XMLTYPE",
+ "comment": "XMLType column for structured XML storage\nExample: \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003croot\u003e\u003citem id=\"1\" name=\"test\"\u003eContent\u003c/item\u003e\u003c/root\u003e"
+ },
+ {
+ "name": "TIMESTAMP_TZ",
+ "position": 3,
+ "default": "SYSTIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6) WITH TIME ZONE",
+ "comment": "Timestamp with timezone: YYYY-MM-DD HH24:MI:SS.FF TZR\nDefault: SYSTIMESTAMP (system timestamp with session timezone)"
+ },
+ {
+ "name": "INTERVAL_DS",
+ "position": 4,
+ "nullable": true,
+ "type": "INTERVAL DAY(2) TO SECOND(6)",
+ "comment": "Interval Day to Second: +/-DD HH:MI:SS.FFFFFF\nRange: +/-999999999 days, precision up to nanoseconds"
+ },
+ {
+ "name": "RAW_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "RAW(100)"
+ },
+ {
+ "name": "LONG_RAW_DATA",
+ "position": 6,
+ "nullable": true,
+ "type": "LONG RAW"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Advanced data types testing table\nSupports: XMLType, Timestamps with timezone, Intervals, RAW data\nPerformance: Optimized for OLTP workloads @ 10K+ TPS\nSecurity: Row-level security enabled, audit trails maintained"
+ },
+ {
+ "name": "MULTILANG_CONTENT",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE_EN",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "English title field"
+ },
+ {
+ "name": "TITLE_ES",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Título en español"
+ },
+ {
+ "name": "TITLE_ZH",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP",
+ "comment": "中文标题字段 - 支持简体和繁体中文"
+ },
+ {
+ "name": "CONTENT_TEXT",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Content field supporting:\n1. HTML tags: \u003cb\u003ebold\u003c/b\u003e, \u003ci\u003eitalic\u003c/i\u003e, \u003ca href=\"http://example.com\"\u003elinks\u003c/a\u003e\n2. Markdown: **bold**, *italic*, [link](url), backtick-code-backtick\n3. Special symbols: © ® ™ § ¶ † ‡ • … ‰ ′ ″\n4. Emojis: 😀 😃 😄 😁 🚀 ⭐ 🎉 💯\n5. Mathematical: ∀x∈ℝ: x² ≥ 0, ∑(i=1 to n) i = n(n+1)/2"
+ },
+ {
+ "name": "TAGS",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(1000 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "XML tags: \u003ctag type=\"category\" value=\"news\"/\u003e\u003ctag type=\"priority\" value=\"high\"/\u003eEnd of XML"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Multilingual content: English, Español, 中文, العربية, Русский, 日本語"
+ },
+ {
+ "name": "SPECIAL_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "DATA_VALUE",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(500 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Data value field - supports NULL, empty strings, and 'quoted' content"
+ },
+ {
+ "name": "METADATA_JSON",
+ "position": 3,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "JSON metadata: {\"key\": \"value\", \"array\": [1,2,3]}"
+ },
+ {
+ "name": "UNICODE_TEXT",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Unicode text support:\nLine 1: Basic ASCII text\nLine 2: Special chars !@#$%^\u0026*()_+-={}[]|;:,.\u003c\u003e?\nLine 3: Math symbols ≤ ≥ ± × ÷ ∑ ∏ ∆ π\nLine 4: Currencies $ € £ ¥ ₹"
+ },
+ {
+ "name": "BINARY_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "BLOB",
+ "comment": "Binary data storage\\nSupports: images, documents, archives\\tTab-separated info\\r\\nWindows line endings"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Category field: use % for wildcard searches, _ for single char matching"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Status field - values: 'ACTIVE', 'INACTIVE', 'PENDING'; DROP TABLE users; --"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Table containing \"special\" data with various formats \u0026 types"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.sql b/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.sql
new file mode 100644
index 0000000000..5e17705356
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/comments_with_special_characters.sql
@@ -0,0 +1,26 @@
+DROP TABLE "COMPLEX_TYPES";
+
+COMMENT ON TABLE "MULTILANG_CONTENT" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_EN" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ES" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ZH" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."CONTENT_TEXT" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TAGS" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_EN" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ES" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ZH" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."CONTENT_TEXT" IS '';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TAGS" IS '';
+COMMENT ON TABLE "SPECIAL_DATA" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."DATA_VALUE" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."METADATA_JSON" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."UNICODE_TEXT" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."BINARY_DATA" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."CATEGORY" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."STATUS" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."DATA_VALUE" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."METADATA_JSON" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."UNICODE_TEXT" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."BINARY_DATA" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."CATEGORY" IS '';
+COMMENT ON COLUMN "SPECIAL_DATA"."STATUS" IS '';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.json b/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.json
new file mode 100644
index 0000000000..fc351bd62b
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.json
@@ -0,0 +1,373 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "DEPARTMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "MANAGER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_MANAGER",
+ "columns": [
+ "MANAGER_ID"
+ ],
+ "referencedTable": "EMPLOYEES",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "EMPLOYEES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "DEPARTMENT_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_DEPT",
+ "columns": [
+ "DEPARTMENT_ID"
+ ],
+ "referencedTable": "DEPARTMENTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "DEPARTMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "MANAGER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_MANAGER",
+ "columns": [
+ "MANAGER_ID"
+ ],
+ "referencedTable": "EMPLOYEES",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "EMPLOYEES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "DEPARTMENT_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_DEPT",
+ "columns": [
+ "DEPARTMENT_ID"
+ ],
+ "referencedTable": "DEPARTMENTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "DEPT_EMPLOYEE_COUNT",
+ "definition": "SELECT D.ID AS DEPT_ID, D.NAME AS DEPT_NAME, COUNT(E.ID) AS EMP_COUNT\nFROM DEPARTMENTS D\nLEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID\nGROUP BY D.ID, D.NAME",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ },
+ {
+ "name": "DEPT_MANAGER_SUMMARY",
+ "definition": "SELECT \n DS.DEPT_ID,\n DS.DEPT_NAME,\n DS.EMP_COUNT,\n DS.AVG_SALARY,\n M.NAME AS MANAGER_NAME\nFROM DEPT_SUMMARY DS\nJOIN DEPARTMENTS D ON DS.DEPT_ID = D.ID\nLEFT JOIN EMPLOYEES M ON D.MANAGER_ID = M.ID",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPT_SUMMARY",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AVG_SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "MANAGER_NAME",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ]
+ },
+ {
+ "name": "DEPT_SUMMARY",
+ "definition": "SELECT \n DEC.DEPT_ID,\n DEC.DEPT_NAME,\n DEC.EMP_COUNT,\n NVL(AVG(E.SALARY), 0) AS AVG_SALARY\nFROM DEPT_EMPLOYEE_COUNT DEC\nLEFT JOIN EMPLOYEES E ON DEC.DEPT_ID = E.DEPARTMENT_ID\nGROUP BY DEC.DEPT_ID, DEC.DEPT_NAME, DEC.EMP_COUNT",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPT_EMPLOYEE_COUNT",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AVG_SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "MV_DEPT_STATS",
+ "definition": "SELECT \n D.ID AS DEPT_ID,\n D.NAME AS DEPT_NAME,\n COUNT(E.ID) AS TOTAL_EMPLOYEES,\n NVL(SUM(E.SALARY), 0) AS TOTAL_PAYROLL,\n NVL(AVG(E.SALARY), 0) AS AVG_SALARY,\n NVL(MAX(E.SALARY), 0) AS MAX_SALARY,\n NVL(MIN(E.SALARY), 0) AS MIN_SALARY\nFROM DEPARTMENTS D\nLEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID\nGROUP BY D.ID, D.NAME\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.MV_DEPT_STATS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "MV_DEPT_STATS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.sql b/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.sql
new file mode 100644
index 0000000000..c42b25d6f4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/complex_view_dependencies.sql
@@ -0,0 +1,4 @@
+DROP VIEW "DEPT_EMPLOYEE_COUNT";
+DROP VIEW "DEPT_MANAGER_SUMMARY";
+DROP VIEW "DEPT_SUMMARY";
+DROP MATERIALIZED VIEW "MV_DEPT_STATS";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.json b/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.json
new file mode 100644
index 0000000000..91bf15dfe4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.json
@@ -0,0 +1,153 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_AT",
+ "position": 5,
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USERNAME",
+ "expressions": [
+ "\"USERNAME\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "UK_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {}
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.sql b/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.sql
new file mode 100644
index 0000000000..b8b4b45285
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/create_tables_with_fk.sql
@@ -0,0 +1,21 @@
+CREATE TABLE "USERS" (
+ "ID" NUMBER DEFAULT "TESTSCHEMA"."ISEQ$$_0000002".nextval NOT NULL,
+ "USERNAME" VARCHAR2(50 BYTE) NOT NULL,
+ "EMAIL" VARCHAR2(100 BYTE) NOT NULL,
+ "CREATED_AT" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP
+);
+ALTER TABLE "USERS" ADD CONSTRAINT "SYS_C0000002" PRIMARY KEY (ID);
+CREATE INDEX "IDX_USERNAME" ON "USERS" ("USERNAME" ASC);
+CREATE UNIQUE INDEX "UK_EMAIL" ON "USERS" ("EMAIL" ASC);
+
+CREATE TABLE "POSTS" (
+ "ID" NUMBER DEFAULT "TESTSCHEMA"."ISEQ$$_0000001".nextval NOT NULL,
+ "USER_ID" NUMBER NOT NULL,
+ "TITLE" VARCHAR2(200 BYTE) NOT NULL,
+ "CONTENT" CLOB,
+ "PUBLISHED_AT" TIMESTAMP(6)
+);
+ALTER TABLE "POSTS" ADD CONSTRAINT "SYS_C0000001" PRIMARY KEY (ID);
+CREATE INDEX "IDX_USER_ID" ON "POSTS" ("USER_ID" ASC);
+
+ALTER TABLE "POSTS" ADD CONSTRAINT "FK_USER" FOREIGN KEY ("USER_ID") REFERENCES "USERS" ("ID") ON DELETE CASCADE;
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.json
new file mode 100644
index 0000000000..d6110d1c5b
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.json
@@ -0,0 +1,321 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUTHORS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "EMAIL"
+ ],
+ "unique": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "BOOKS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 2,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "AUTHOR_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ISBN",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_YEAR",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRICE",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(8,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000004",
+ "expressions": [
+ "ISBN"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_BOOKS_AUTHOR",
+ "expressions": [
+ "\"AUTHOR_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_BOOKS_YEAR",
+ "expressions": [
+ "\"PUBLISHED_YEAR\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_AUTHOR",
+ "columns": [
+ "AUTHOR_ID"
+ ],
+ "referencedTable": "AUTHORS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ },
+ {
+ "name": "CHECK_YEAR_VALID",
+ "expression": "PUBLISHED_YEAR \u003e= 1000 AND PUBLISHED_YEAR \u003c= 2100"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUTHORS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "EMAIL"
+ ],
+ "unique": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "BOOKS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 2,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "AUTHOR_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ISBN",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_YEAR",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRICE",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(8,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000004",
+ "expressions": [
+ "ISBN"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_BOOKS_AUTHOR",
+ "expressions": [
+ "\"AUTHOR_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_BOOKS_YEAR",
+ "expressions": [
+ "\"PUBLISHED_YEAR\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_AUTHOR_NEW",
+ "columns": [
+ "AUTHOR_ID"
+ ],
+ "referencedTable": "AUTHORS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ },
+ {
+ "name": "CHECK_TITLE_LENGTH",
+ "expression": "LENGTH(TITLE) \u003e= 3"
+ },
+ {
+ "name": "CHECK_YEAR_EXTENDED",
+ "expression": "PUBLISHED_YEAR \u003e= 1000 AND PUBLISHED_YEAR \u003c= 2030"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.sql
new file mode 100644
index 0000000000..bdbf404172
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_and_recreate_constraints.sql
@@ -0,0 +1,6 @@
+ALTER TABLE "BOOKS" DROP CONSTRAINT "FK_AUTHOR_NEW";
+ALTER TABLE "BOOKS" DROP CONSTRAINT "CHECK_TITLE_LENGTH";
+ALTER TABLE "BOOKS" DROP CONSTRAINT "CHECK_YEAR_EXTENDED";
+
+ALTER TABLE "BOOKS" ADD CONSTRAINT "CHECK_YEAR_VALID" CHECK (PUBLISHED_YEAR >= 1000 AND PUBLISHED_YEAR <= 2100);
+ALTER TABLE "BOOKS" ADD CONSTRAINT "FK_AUTHOR" FOREIGN KEY ("AUTHOR_ID") REFERENCES "AUTHORS" ("ID");
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.json
new file mode 100644
index 0000000000..28c57ff2d4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.json
@@ -0,0 +1,160 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SUPPLIER_ID",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_NAME",
+ "expressions": [
+ "\"NAME\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_NAME_LENGTH",
+ "expression": "LENGTH(NAME) \u003e= 3"
+ },
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SUPPLIER_ID",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.sql
new file mode 100644
index 0000000000..c71a886400
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_indexes_and_constraints.sql
@@ -0,0 +1,5 @@
+CREATE INDEX "IDX_PRODUCTS_CATEGORY" ON "PRODUCTS" ("CATEGORY" ASC);
+CREATE UNIQUE INDEX "IDX_PRODUCTS_NAME" ON "PRODUCTS" ("NAME" ASC);
+CREATE INDEX "IDX_PRODUCTS_PRICE" ON "PRODUCTS" ("PRICE" ASC);
+ALTER TABLE "PRODUCTS" ADD CONSTRAINT "CHECK_NAME_LENGTH" CHECK (LENGTH(NAME) >= 3);
+ALTER TABLE "PRODUCTS" ADD CONSTRAINT "CHECK_PRICE_POSITIVE" CHECK (PRICE > 0);
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.json b/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.json
new file mode 100644
index 0000000000..860f67fe3e
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.json
@@ -0,0 +1,52 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SIMPLE_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TRANSACTION_SEQ\".NEXTVAL",
+ "type": "NUMBER"
+ },
+ {
+ "name": "MESSAGE",
+ "position": 2,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "sequences": [
+ {
+ "name": "TRANSACTION_SEQ"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {}
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.sql b/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.sql
new file mode 100644
index 0000000000..0bf7acbc41
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_sequence.sql
@@ -0,0 +1,7 @@
+CREATE SEQUENCE "TRANSACTION_SEQ";
+CREATE TABLE "SIMPLE_LOG" (
+ "ID" NUMBER DEFAULT "TRANSACTION_SEQ".NEXTVAL NOT NULL,
+ "MESSAGE" CLOB NOT NULL
+);
+ALTER TABLE "SIMPLE_LOG" ADD CONSTRAINT "SYS_C0000001" PRIMARY KEY (ID);
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.json
new file mode 100644
index 0000000000..4e1fe8e237
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.json
@@ -0,0 +1,160 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "SALE_AMOUNT",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 4,
+ "type": "DATE"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "MONTHLY_SALES",
+ "definition": "SELECT \n EXTRACT(YEAR FROM SALE_DATE) AS YEAR_VAL,\n EXTRACT(MONTH FROM SALE_DATE) AS MONTH_VAL,\n SUM(SALE_AMOUNT) AS TOTAL_SALES\nFROM SALES\nGROUP BY EXTRACT(YEAR FROM SALE_DATE), EXTRACT(MONTH FROM SALE_DATE)",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "SALES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "YEAR_VAL",
+ "position": 1,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "MONTH_VAL",
+ "position": 2,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL_SALES",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_DISCOUNT",
+ "definition": "FUNCTION CALCULATE_DISCOUNT(AMOUNT NUMBER)\nRETURN NUMBER\nIS\nBEGIN\n RETURN AMOUNT * 0.1;\nEND;"
+ },
+ {
+ "name": "GET_MONTHLY_TOTAL",
+ "definition": "FUNCTION GET_MONTHLY_TOTAL(YEAR_PARAM NUMBER, MONTH_PARAM NUMBER)\nRETURN NUMBER\nIS\n V_TOTAL NUMBER;\nBEGIN\n SELECT NVL(SUM(SALE_AMOUNT), 0) INTO V_TOTAL\n FROM SALES\n WHERE EXTRACT(YEAR FROM SALE_DATE) = YEAR_PARAM\n AND EXTRACT(MONTH FROM SALE_DATE) = MONTH_PARAM;\n \n RETURN V_TOTAL;\nEND;"
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "TOP_PRODUCTS",
+ "definition": "SELECT \n PRODUCT_NAME,\n COUNT(*) AS SALE_COUNT,\n SUM(SALE_AMOUNT) AS TOTAL_REVENUE\nFROM SALES\nGROUP BY PRODUCT_NAME\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.TOP_PRODUCTS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "SALES",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "TOP_PRODUCTS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "SALE_AMOUNT",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 4,
+ "type": "DATE"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.sql
new file mode 100644
index 0000000000..c22e52e34e
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/drop_views_and_functions.sql
@@ -0,0 +1,35 @@
+CREATE OR REPLACE FUNCTION CALCULATE_DISCOUNT(AMOUNT NUMBER)
+RETURN NUMBER
+IS
+BEGIN
+ RETURN AMOUNT * 0.1;
+END;
+
+CREATE OR REPLACE FUNCTION GET_MONTHLY_TOTAL(YEAR_PARAM NUMBER, MONTH_PARAM NUMBER)
+RETURN NUMBER
+IS
+ V_TOTAL NUMBER;
+BEGIN
+ SELECT NVL(SUM(SALE_AMOUNT), 0) INTO V_TOTAL
+ FROM SALES
+ WHERE EXTRACT(YEAR FROM SALE_DATE) = YEAR_PARAM
+ AND EXTRACT(MONTH FROM SALE_DATE) = MONTH_PARAM;
+
+ RETURN V_TOTAL;
+END;
+
+CREATE VIEW "MONTHLY_SALES" AS SELECT
+ EXTRACT(YEAR FROM SALE_DATE) AS YEAR_VAL,
+ EXTRACT(MONTH FROM SALE_DATE) AS MONTH_VAL,
+ SUM(SALE_AMOUNT) AS TOTAL_SALES
+FROM SALES
+GROUP BY EXTRACT(YEAR FROM SALE_DATE), EXTRACT(MONTH FROM SALE_DATE);
+CREATE MATERIALIZED VIEW "TOP_PRODUCTS" AS SELECT
+ PRODUCT_NAME,
+ COUNT(*) AS SALE_COUNT,
+ SUM(SALE_AMOUNT) AS TOTAL_REVENUE
+FROM SALES
+GROUP BY PRODUCT_NAME
+;
+COMMENT ON MATERIALIZED VIEW "TOP_PRODUCTS" IS 'snapshot table for snapshot TESTSCHEMA.TOP_PRODUCTS';
+COMMENT ON MATERIALIZED VIEW "TOP_PRODUCTS" IS 'snapshot table for snapshot TESTSCHEMA.TOP_PRODUCTS';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.json b/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.json
new file mode 100644
index 0000000000..82f95d75f4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.json
@@ -0,0 +1,163 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "TEST_COLUMNS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "COL_VARCHAR",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_NUMBER",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "COL_DATE",
+ "position": 4,
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "COL_CLOB",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_NULLABLE",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_WITH_DEFAULT",
+ "position": 7,
+ "default": "'DEFAULT_VALUE'",
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "TEST_COLUMNS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "COL_VARCHAR",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_NUMBER",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER(15,3)"
+ },
+ {
+ "name": "COL_DATE",
+ "position": 4,
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "COL_NULLABLE",
+ "position": 5,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_WITH_DEFAULT",
+ "position": 6,
+ "default": "'NEW_DEFAULT'",
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_TIMESTAMP",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "COL_BOOLEAN",
+ "position": 8,
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHK_NUMBER_POSITIVE",
+ "expression": "COL_NUMBER \u003e 0"
+ },
+ {
+ "name": "CHK_VARCHAR_LENGTH",
+ "expression": "LENGTH(COL_VARCHAR) \u003e= 5"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.sql b/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.sql
new file mode 100644
index 0000000000..72032aa2d8
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/edge_case_column_operations.sql
@@ -0,0 +1,11 @@
+ALTER TABLE "TEST_COLUMNS" DROP CONSTRAINT "CHK_NUMBER_POSITIVE";
+ALTER TABLE "TEST_COLUMNS" DROP CONSTRAINT "CHK_VARCHAR_LENGTH";
+ALTER TABLE "TEST_COLUMNS" DROP COLUMN "COL_TIMESTAMP";
+ALTER TABLE "TEST_COLUMNS" DROP COLUMN "COL_BOOLEAN";
+
+ALTER TABLE "TEST_COLUMNS" ADD "COL_CLOB" CLOB;
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_VARCHAR" VARCHAR2(50 BYTE);
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_NUMBER" NUMBER(10,2);
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_NULLABLE" NULL;
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_WITH_DEFAULT" DEFAULT NULL;
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_WITH_DEFAULT" DEFAULT 'DEFAULT_VALUE';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.json b/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.json
new file mode 100644
index 0000000000..d221d38569
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.json
@@ -0,0 +1,250 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "INVENTORY",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER",
+ "comment": "Primary key for inventory records"
+ },
+ {
+ "name": "PRODUCT_CODE",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product identification code"
+ },
+ {
+ "name": "STOCK_LEVEL",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Current stock quantity"
+ },
+ {
+ "name": "MIN_STOCK",
+ "position": 4,
+ "default": "10",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Minimum stock threshold"
+ },
+ {
+ "name": "MAX_STOCK",
+ "position": 5,
+ "default": "1000",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Maximum stock capacity"
+ },
+ {
+ "name": "WAREHOUSE_ID",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Warehouse location identifier"
+ },
+ {
+ "name": "LAST_UPDATED",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Initial inventory tracking table"
+ },
+ {
+ "name": "SUPPLIERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Supplier company name"
+ },
+ {
+ "name": "CONTACT_EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Primary contact email"
+ },
+ {
+ "name": "RATING",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(2,1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Supplier information table"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "INVENTORY",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER",
+ "comment": "Primary key for inventory records"
+ },
+ {
+ "name": "PRODUCT_CODE",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Updated: Standardized product SKU following new naming convention"
+ },
+ {
+ "name": "STOCK_LEVEL",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Updated: Real-time stock quantity with automated updates"
+ },
+ {
+ "name": "MIN_STOCK",
+ "position": 4,
+ "default": "10",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Updated: Dynamic minimum threshold based on sales velocity"
+ },
+ {
+ "name": "MAX_STOCK",
+ "position": 5,
+ "default": "1000",
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "WAREHOUSE_ID",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "LAST_UPDATED",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)",
+ "comment": "Timestamp of last inventory update or modification"
+ },
+ {
+ "name": "REORDER_POINT",
+ "position": 8,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Calculated reorder point based on lead time and demand"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Updated inventory management system with enhanced tracking capabilities"
+ },
+ {
+ "name": "SUPPLIERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Supplier company name"
+ },
+ {
+ "name": "CONTACT_EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "RATING",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(2,1)",
+ "comment": "Supplier performance rating (1.0 to 5.0 scale)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.sql b/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.sql
new file mode 100644
index 0000000000..f989f4ca97
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/modify_and_drop_comments.sql
@@ -0,0 +1,20 @@
+ALTER TABLE "INVENTORY" DROP COLUMN "REORDER_POINT";
+
+COMMENT ON TABLE "INVENTORY" IS 'Initial inventory tracking table';
+COMMENT ON COLUMN "INVENTORY"."PRODUCT_CODE" IS 'Product identification code';
+COMMENT ON COLUMN "INVENTORY"."STOCK_LEVEL" IS 'Current stock quantity';
+COMMENT ON COLUMN "INVENTORY"."MIN_STOCK" IS 'Minimum stock threshold';
+COMMENT ON COLUMN "INVENTORY"."MAX_STOCK" IS 'Maximum stock capacity';
+COMMENT ON COLUMN "INVENTORY"."WAREHOUSE_ID" IS 'Warehouse location identifier';
+COMMENT ON COLUMN "INVENTORY"."LAST_UPDATED" IS '';
+COMMENT ON COLUMN "INVENTORY"."PRODUCT_CODE" IS 'Product identification code';
+COMMENT ON COLUMN "INVENTORY"."STOCK_LEVEL" IS 'Current stock quantity';
+COMMENT ON COLUMN "INVENTORY"."MIN_STOCK" IS 'Minimum stock threshold';
+COMMENT ON COLUMN "INVENTORY"."MAX_STOCK" IS 'Maximum stock capacity';
+COMMENT ON COLUMN "INVENTORY"."WAREHOUSE_ID" IS 'Warehouse location identifier';
+COMMENT ON COLUMN "INVENTORY"."LAST_UPDATED" IS '';
+COMMENT ON TABLE "SUPPLIERS" IS 'Supplier information table';
+COMMENT ON COLUMN "SUPPLIERS"."CONTACT_EMAIL" IS 'Primary contact email';
+COMMENT ON COLUMN "SUPPLIERS"."RATING" IS '';
+COMMENT ON COLUMN "SUPPLIERS"."CONTACT_EMAIL" IS 'Primary contact email';
+COMMENT ON COLUMN "SUPPLIERS"."RATING" IS '';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.json
new file mode 100644
index 0000000000..3d7bc1a0a4
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.json
@@ -0,0 +1,144 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 2,
+ "type": "DATE"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AMOUNT",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "REGION",
+ "position": 6,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "UK_SALES_DATE_CUSTOMER",
+ "expressions": [
+ "SALE_DATE",
+ "CUSTOMER_ID",
+ "PRODUCT_ID"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_SALES_MONTH_YEAR",
+ "expressions": [
+ "EXTRACT(YEAR FROM \"SALE_DATE\")",
+ "EXTRACT(MONTH FROM \"SALE_DATE\")"
+ ],
+ "descending": [
+ false,
+ false
+ ],
+ "type": "FUNCTION-BASED NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_SALES_REGION_AMOUNT",
+ "expressions": [
+ "\"REGION\"",
+ "\"AMOUNT\""
+ ],
+ "descending": [
+ false,
+ true
+ ],
+ "type": "FUNCTION-BASED NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHK_AMOUNT_RANGE",
+ "expression": "AMOUNT \u003e 0 AND AMOUNT \u003c= 999999.99"
+ },
+ {
+ "name": "CHK_REGION_VALID",
+ "expression": "REGION IN ('NORTH', 'SOUTH', 'EAST', 'WEST', 'CENTRAL')"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 2,
+ "type": "DATE"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AMOUNT",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "REGION",
+ "position": 6,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.sql
new file mode 100644
index 0000000000..d575e1aaff
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_advanced_indexes_and_constraints.sql
@@ -0,0 +1,5 @@
+CREATE INDEX "IDX_SALES_MONTH_YEAR" ON "SALES_DATA" (EXTRACT(YEAR FROM "SALE_DATE") ASC, EXTRACT(MONTH FROM "SALE_DATE") ASC);
+CREATE INDEX "IDX_SALES_REGION_AMOUNT" ON "SALES_DATA" ("REGION" ASC, "AMOUNT" DESC);
+ALTER TABLE "SALES_DATA" ADD CONSTRAINT "UK_SALES_DATE_CUSTOMER" UNIQUE (SALE_DATE, CUSTOMER_ID, PRODUCT_ID);
+ALTER TABLE "SALES_DATA" ADD CONSTRAINT "CHK_AMOUNT_RANGE" CHECK (AMOUNT > 0 AND AMOUNT <= 999999.99);
+ALTER TABLE "SALES_DATA" ADD CONSTRAINT "CHK_REGION_VALID" CHECK (REGION IN ('NORTH', 'SOUTH', 'EAST', 'WEST', 'CENTRAL'));
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.json
new file mode 100644
index 0000000000..4b8ca6909c
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.json
@@ -0,0 +1,228 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(30 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 6,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "STOCK_QUANTITY",
+ "position": 8,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "WEIGHT",
+ "position": 9,
+ "nullable": true,
+ "type": "NUMBER(5,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CREATED_AT",
+ "expressions": [
+ "\"CREATED_AT\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_NAME_CATEGORY",
+ "expressions": [
+ "\"NAME\"",
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false,
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ },
+ {
+ "name": "CHECK_STOCK_NON_NEGATIVE",
+ "expression": "STOCK_QUANTITY \u003e= 0"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(8,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(30 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 6,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.sql
new file mode 100644
index 0000000000..2ad2b39d08
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_alter_table_columns.sql
@@ -0,0 +1,10 @@
+ALTER TABLE "PRODUCTS" ADD "CREATED_AT" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE "PRODUCTS" ADD "STOCK_QUANTITY" NUMBER DEFAULT 0;
+ALTER TABLE "PRODUCTS" ADD "WEIGHT" NUMBER(5,2);
+ALTER TABLE "PRODUCTS" MODIFY "NAME" VARCHAR2(100 BYTE);
+ALTER TABLE "PRODUCTS" MODIFY "PRICE" NUMBER(10,2);
+ALTER TABLE "PRODUCTS" MODIFY "DESCRIPTION" NOT NULL;
+CREATE INDEX "IDX_PRODUCTS_CREATED_AT" ON "PRODUCTS" ("CREATED_AT" ASC);
+CREATE UNIQUE INDEX "IDX_PRODUCTS_NAME_CATEGORY" ON "PRODUCTS" ("NAME" ASC, "CATEGORY" ASC);
+ALTER TABLE "PRODUCTS" ADD CONSTRAINT "CHECK_PRICE_POSITIVE" CHECK (PRICE > 0);
+ALTER TABLE "PRODUCTS" ADD CONSTRAINT "CHECK_STOCK_NON_NEGATIVE" CHECK (STOCK_QUANTITY >= 0);
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.json
new file mode 100644
index 0000000000..82d6c3b657
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.json
@@ -0,0 +1,321 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "COMMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "POST_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 5,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_COMMENT_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ },
+ {
+ "name": "FK_POST",
+ "columns": [
+ "POST_ID"
+ ],
+ "referencedTable": "POSTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_POSTS_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_TITLE_LENGTH",
+ "expression": "LENGTH(TITLE) \u003e 0"
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "IS_ACTIVE",
+ "position": 5,
+ "default": "1",
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_POSTS_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.sql
new file mode 100644
index 0000000000..e50d14f95f
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_basic_table_operations.sql
@@ -0,0 +1,14 @@
+ALTER TABLE "USERS" ADD "IS_ACTIVE" NUMBER(1) DEFAULT 1;
+CREATE TABLE "COMMENTS" (
+ "ID" NUMBER DEFAULT "TESTSCHEMA"."ISEQ$$_0000001".nextval NOT NULL,
+ "POST_ID" NUMBER NOT NULL,
+ "USER_ID" NUMBER NOT NULL,
+ "CONTENT" CLOB NOT NULL,
+ "CREATED_AT" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP
+);
+ALTER TABLE "COMMENTS" ADD CONSTRAINT "SYS_C0000001" PRIMARY KEY (ID);
+
+ALTER TABLE "COMMENTS" ADD CONSTRAINT "FK_COMMENT_USER" FOREIGN KEY ("USER_ID") REFERENCES "USERS" ("ID");
+ALTER TABLE "COMMENTS" ADD CONSTRAINT "FK_POST" FOREIGN KEY ("POST_ID") REFERENCES "POSTS" ("ID");
+ALTER TABLE "POSTS" ADD CONSTRAINT "CHECK_TITLE_LENGTH" CHECK (LENGTH(TITLE) > 0);
+CREATE INDEX "IDX_USERS_EMAIL" ON "USERS" ("EMAIL" ASC);
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.json
new file mode 100644
index 0000000000..1006bcfb74
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.json
@@ -0,0 +1,258 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PREFERRED_ORDER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PREFERRED_ORDER",
+ "columns": [
+ "PREFERRED_ORDER_ID"
+ ],
+ "referencedTable": "ORDERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 3,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_CUSTOMER",
+ "columns": [
+ "CUSTOMER_ID"
+ ],
+ "referencedTable": "CUSTOMERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ORDER_ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 4,
+ "type": "NUMBER"
+ },
+ {
+ "name": "UNIT_PRICE",
+ "position": 5,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_ORDER_ITEM",
+ "columns": [
+ "ORDER_ID"
+ ],
+ "referencedTable": "ORDERS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ],
+ "triggers": [
+ {
+ "name": "TRG_UPDATE_ORDER_TOTAL",
+ "event": "INSERT OR UPDATE OR DELETE",
+ "timing": "AFTER EACH ROW",
+ "body": "CREATE OR REPLACE TRIGGER TRG_UPDATE_ORDER_TOTAL\nAFTER INSERT OR UPDATE OR DELETE ON ORDER_ITEMS\nFOR EACH ROW\nDECLARE\n V_ORDER_ID NUMBER;\n V_TOTAL NUMBER(10, 2);\nBEGIN\n -- Get order ID\n IF INSERTING OR UPDATING THEN\n V_ORDER_ID := :NEW.ORDER_ID;\n ELSE\n V_ORDER_ID := :OLD.ORDER_ID;\n END IF;\n \n -- Calculate new total\n SELECT NVL(SUM(QUANTITY * UNIT_PRICE), 0) INTO V_TOTAL\n FROM ORDER_ITEMS\n WHERE ORDER_ID = V_ORDER_ID;\n \n -- Update order total\n UPDATE ORDERS SET TOTAL_AMOUNT = V_TOTAL WHERE ID = V_ORDER_ID;\nEND;"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PREFERRED_ORDER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 3,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.sql
new file mode 100644
index 0000000000..09dd4ecf94
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_circular_foreign_key_dependencies.sql
@@ -0,0 +1,34 @@
+CREATE TABLE "ORDER_ITEMS" (
+ "ID" NUMBER DEFAULT "TESTSCHEMA"."ISEQ$$_0000003".nextval NOT NULL,
+ "ORDER_ID" NUMBER NOT NULL,
+ "PRODUCT_NAME" VARCHAR2(100 BYTE) NOT NULL,
+ "QUANTITY" NUMBER NOT NULL,
+ "UNIT_PRICE" NUMBER(10,2) NOT NULL
+);
+ALTER TABLE "ORDER_ITEMS" ADD CONSTRAINT "SYS_C0000003" PRIMARY KEY (ID);
+CREATE OR REPLACE TRIGGER TRG_UPDATE_ORDER_TOTAL
+AFTER INSERT OR UPDATE OR DELETE ON ORDER_ITEMS
+FOR EACH ROW
+DECLARE
+ V_ORDER_ID NUMBER;
+ V_TOTAL NUMBER(10, 2);
+BEGIN
+ -- Get order ID
+ IF INSERTING OR UPDATING THEN
+ V_ORDER_ID := :NEW.ORDER_ID;
+ ELSE
+ V_ORDER_ID := :OLD.ORDER_ID;
+ END IF;
+
+ -- Calculate new total
+ SELECT NVL(SUM(QUANTITY * UNIT_PRICE), 0) INTO V_TOTAL
+ FROM ORDER_ITEMS
+ WHERE ORDER_ID = V_ORDER_ID;
+
+ -- Update order total
+ UPDATE ORDERS SET TOTAL_AMOUNT = V_TOTAL WHERE ID = V_ORDER_ID;
+END;
+
+ALTER TABLE "ORDER_ITEMS" ADD CONSTRAINT "FK_ORDER_ITEM" FOREIGN KEY ("ORDER_ID") REFERENCES "ORDERS" ("ID") ON DELETE CASCADE;
+ALTER TABLE "CUSTOMERS" ADD CONSTRAINT "FK_PREFERRED_ORDER" FOREIGN KEY ("PREFERRED_ORDER_ID") REFERENCES "ORDERS" ("ID");
+ALTER TABLE "ORDERS" ADD CONSTRAINT "FK_CUSTOMER" FOREIGN KEY ("CUSTOMER_ID") REFERENCES "CUSTOMERS" ("ID");
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.json
new file mode 100644
index 0000000000..247dd07689
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.json
@@ -0,0 +1,331 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "COMPLEX_TYPES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "XML_DATA",
+ "position": 2,
+ "nullable": true,
+ "type": "XMLTYPE",
+ "comment": "XMLType column for structured XML storage\nExample: \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003croot\u003e\u003citem id=\"1\" name=\"test\"\u003eContent\u003c/item\u003e\u003c/root\u003e"
+ },
+ {
+ "name": "TIMESTAMP_TZ",
+ "position": 3,
+ "default": "SYSTIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6) WITH TIME ZONE",
+ "comment": "Timestamp with timezone: YYYY-MM-DD HH24:MI:SS.FF TZR\nDefault: SYSTIMESTAMP (system timestamp with session timezone)"
+ },
+ {
+ "name": "INTERVAL_DS",
+ "position": 4,
+ "nullable": true,
+ "type": "INTERVAL DAY(2) TO SECOND(6)",
+ "comment": "Interval Day to Second: +/-DD HH:MI:SS.FFFFFF\nRange: +/-999999999 days, precision up to nanoseconds"
+ },
+ {
+ "name": "RAW_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "RAW(100)"
+ },
+ {
+ "name": "LONG_RAW_DATA",
+ "position": 6,
+ "nullable": true,
+ "type": "LONG RAW"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Advanced data types testing table\nSupports: XMLType, Timestamps with timezone, Intervals, RAW data\nPerformance: Optimized for OLTP workloads @ 10K+ TPS\nSecurity: Row-level security enabled, audit trails maintained"
+ },
+ {
+ "name": "MULTILANG_CONTENT",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE_EN",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "English title field"
+ },
+ {
+ "name": "TITLE_ES",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Título en español"
+ },
+ {
+ "name": "TITLE_ZH",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP",
+ "comment": "中文标题字段 - 支持简体和繁体中文"
+ },
+ {
+ "name": "CONTENT_TEXT",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Content field supporting:\n1. HTML tags: \u003cb\u003ebold\u003c/b\u003e, \u003ci\u003eitalic\u003c/i\u003e, \u003ca href=\"http://example.com\"\u003elinks\u003c/a\u003e\n2. Markdown: **bold**, *italic*, [link](url), backtick-code-backtick\n3. Special symbols: © ® ™ § ¶ † ‡ • … ‰ ′ ″\n4. Emojis: 😀 😃 😄 😁 🚀 ⭐ 🎉 💯\n5. Mathematical: ∀x∈ℝ: x² ≥ 0, ∑(i=1 to n) i = n(n+1)/2"
+ },
+ {
+ "name": "TAGS",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(1000 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "XML tags: \u003ctag type=\"category\" value=\"news\"/\u003e\u003ctag type=\"priority\" value=\"high\"/\u003eEnd of XML"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Multilingual content: English, Español, 中文, العربية, Русский, 日本語"
+ },
+ {
+ "name": "SPECIAL_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "DATA_VALUE",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(500 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Data value field - supports NULL, empty strings, and 'quoted' content"
+ },
+ {
+ "name": "METADATA_JSON",
+ "position": 3,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "JSON metadata: {\"key\": \"value\", \"array\": [1,2,3]}"
+ },
+ {
+ "name": "UNICODE_TEXT",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Unicode text support:\nLine 1: Basic ASCII text\nLine 2: Special chars !@#$%^\u0026*()_+-={}[]|;:,.\u003c\u003e?\nLine 3: Math symbols ≤ ≥ ± × ÷ ∑ ∏ ∆ π\nLine 4: Currencies $ € £ ¥ ₹"
+ },
+ {
+ "name": "BINARY_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "BLOB",
+ "comment": "Binary data storage\\nSupports: images, documents, archives\\tTab-separated info\\r\\nWindows line endings"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Category field: use % for wildcard searches, _ for single char matching"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Status field - values: 'ACTIVE', 'INACTIVE', 'PENDING'; DROP TABLE users; --"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Table containing \"special\" data with various formats \u0026 types"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "MULTILANG_CONTENT",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE_EN",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TITLE_ES",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TITLE_ZH",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT_TEXT",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TAGS",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(1000 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "SPECIAL_DATA",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "DATA_VALUE",
+ "position": 2,
+ "nullable": true,
+ "type": "VARCHAR2(500 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "METADATA_JSON",
+ "position": 3,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "UNICODE_TEXT",
+ "position": 4,
+ "nullable": true,
+ "type": "NVARCHAR2(400)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "BINARY_DATA",
+ "position": 5,
+ "nullable": true,
+ "type": "BLOB"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 6,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.sql
new file mode 100644
index 0000000000..8106db9c85
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_comments_with_special_characters.sql
@@ -0,0 +1,63 @@
+CREATE TABLE "COMPLEX_TYPES" (
+ "ID" NUMBER NOT NULL,
+ "XML_DATA" XMLTYPE,
+ "TIMESTAMP_TZ" TIMESTAMP(6) WITH TIME ZONE DEFAULT SYSTIMESTAMP,
+ "INTERVAL_DS" INTERVAL DAY(2) TO SECOND(6),
+ "RAW_DATA" RAW(100),
+ "LONG_RAW_DATA" LONG RAW
+);
+ALTER TABLE "COMPLEX_TYPES" ADD CONSTRAINT "SYS_C0000001" PRIMARY KEY (ID);
+COMMENT ON TABLE "COMPLEX_TYPES" IS 'Advanced data types testing table
+Supports: XMLType, Timestamps with timezone, Intervals, RAW data
+Performance: Optimized for OLTP workloads @ 10K+ TPS
+Security: Row-level security enabled, audit trails maintained';
+COMMENT ON COLUMN "COMPLEX_TYPES"."XML_DATA" IS 'XMLType column for structured XML storage
+Example: <?xml version="1.0" encoding="UTF-8"?>
+<root><item id="1" name="test">Content</item></root>';
+COMMENT ON COLUMN "COMPLEX_TYPES"."TIMESTAMP_TZ" IS 'Timestamp with timezone: YYYY-MM-DD HH24:MI:SS.FF TZR
+Default: SYSTIMESTAMP (system timestamp with session timezone)';
+COMMENT ON COLUMN "COMPLEX_TYPES"."INTERVAL_DS" IS 'Interval Day to Second: +/-DD HH:MI:SS.FFFFFF
+Range: +/-999999999 days, precision up to nanoseconds';
+
+COMMENT ON TABLE "MULTILANG_CONTENT" IS 'Multilingual content: English, Español, 中文, العربية, Русский, 日本語';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_EN" IS 'English title field';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ES" IS 'Título en español';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ZH" IS '中文标题字段 - 支持简体和繁体中文';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."CONTENT_TEXT" IS 'Content field supporting:
+1. HTML tags: <b>bold</b>, <i>italic</i>, <a href="http://example.com">links</a>
+2. Markdown: **bold**, *italic*, [link](url), backtick-code-backtick
+3. Special symbols: © ® ™ § ¶ † ‡ • … ‰ ′ ″
+4. Emojis: 😀 😃 😄 😁 🚀 ⭐ 🎉 💯
+5. Mathematical: ∀x∈ℝ: x² ≥ 0, ∑(i=1 to n) i = n(n+1)/2';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TAGS" IS 'XML tags: <tag type="category" value="news"/><tag type="priority" value="high"/>End of XML';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_EN" IS 'English title field';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ES" IS 'Título en español';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TITLE_ZH" IS '中文标题字段 - 支持简体和繁体中文';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."CONTENT_TEXT" IS 'Content field supporting:
+1. HTML tags: <b>bold</b>, <i>italic</i>, <a href="http://example.com">links</a>
+2. Markdown: **bold**, *italic*, [link](url), backtick-code-backtick
+3. Special symbols: © ® ™ § ¶ † ‡ • … ‰ ′ ″
+4. Emojis: 😀 😃 😄 😁 🚀 ⭐ 🎉 💯
+5. Mathematical: ∀x∈ℝ: x² ≥ 0, ∑(i=1 to n) i = n(n+1)/2';
+COMMENT ON COLUMN "MULTILANG_CONTENT"."TAGS" IS 'XML tags: <tag type="category" value="news"/><tag type="priority" value="high"/>End of XML';
+COMMENT ON TABLE "SPECIAL_DATA" IS 'Table containing "special" data with various formats & types';
+COMMENT ON COLUMN "SPECIAL_DATA"."DATA_VALUE" IS 'Data value field - supports NULL, empty strings, and ''quoted'' content';
+COMMENT ON COLUMN "SPECIAL_DATA"."METADATA_JSON" IS 'JSON metadata: {"key": "value", "array": [1,2,3]}';
+COMMENT ON COLUMN "SPECIAL_DATA"."UNICODE_TEXT" IS 'Unicode text support:
+Line 1: Basic ASCII text
+Line 2: Special chars !@#$%^&*()_+-={}[]|;:,.<>?
+Line 3: Math symbols ≤ ≥ ± × ÷ ∑ ∏ ∆ π
+Line 4: Currencies $ € £ ¥ ₹';
+COMMENT ON COLUMN "SPECIAL_DATA"."BINARY_DATA" IS 'Binary data storage\nSupports: images, documents, archives\tTab-separated info\r\nWindows line endings';
+COMMENT ON COLUMN "SPECIAL_DATA"."CATEGORY" IS 'Category field: use % for wildcard searches, _ for single char matching';
+COMMENT ON COLUMN "SPECIAL_DATA"."STATUS" IS 'Status field - values: ''ACTIVE'', ''INACTIVE'', ''PENDING''; DROP TABLE users; --';
+COMMENT ON COLUMN "SPECIAL_DATA"."DATA_VALUE" IS 'Data value field - supports NULL, empty strings, and ''quoted'' content';
+COMMENT ON COLUMN "SPECIAL_DATA"."METADATA_JSON" IS 'JSON metadata: {"key": "value", "array": [1,2,3]}';
+COMMENT ON COLUMN "SPECIAL_DATA"."UNICODE_TEXT" IS 'Unicode text support:
+Line 1: Basic ASCII text
+Line 2: Special chars !@#$%^&*()_+-={}[]|;:,.<>?
+Line 3: Math symbols ≤ ≥ ± × ÷ ∑ ∏ ∆ π
+Line 4: Currencies $ € £ ¥ ₹';
+COMMENT ON COLUMN "SPECIAL_DATA"."BINARY_DATA" IS 'Binary data storage\nSupports: images, documents, archives\tTab-separated info\r\nWindows line endings';
+COMMENT ON COLUMN "SPECIAL_DATA"."CATEGORY" IS 'Category field: use % for wildcard searches, _ for single char matching';
+COMMENT ON COLUMN "SPECIAL_DATA"."STATUS" IS 'Status field - values: ''ACTIVE'', ''INACTIVE'', ''PENDING''; DROP TABLE users; --';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.json
new file mode 100644
index 0000000000..d7fc48fde9
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.json
@@ -0,0 +1,373 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "DEPARTMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "MANAGER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_MANAGER",
+ "columns": [
+ "MANAGER_ID"
+ ],
+ "referencedTable": "EMPLOYEES",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "EMPLOYEES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "DEPARTMENT_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_DEPT",
+ "columns": [
+ "DEPARTMENT_ID"
+ ],
+ "referencedTable": "DEPARTMENTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "DEPT_EMPLOYEE_COUNT",
+ "definition": "SELECT D.ID AS DEPT_ID, D.NAME AS DEPT_NAME, COUNT(E.ID) AS EMP_COUNT\nFROM DEPARTMENTS D\nLEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID\nGROUP BY D.ID, D.NAME",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ },
+ {
+ "name": "DEPT_MANAGER_SUMMARY",
+ "definition": "SELECT \n DS.DEPT_ID,\n DS.DEPT_NAME,\n DS.EMP_COUNT,\n DS.AVG_SALARY,\n M.NAME AS MANAGER_NAME\nFROM DEPT_SUMMARY DS\nJOIN DEPARTMENTS D ON DS.DEPT_ID = D.ID\nLEFT JOIN EMPLOYEES M ON D.MANAGER_ID = M.ID",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPT_SUMMARY",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AVG_SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "MANAGER_NAME",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ]
+ },
+ {
+ "name": "DEPT_SUMMARY",
+ "definition": "SELECT \n DEC.DEPT_ID,\n DEC.DEPT_NAME,\n DEC.EMP_COUNT,\n NVL(AVG(E.SALARY), 0) AS AVG_SALARY\nFROM DEPT_EMPLOYEE_COUNT DEC\nLEFT JOIN EMPLOYEES E ON DEC.DEPT_ID = E.DEPARTMENT_ID\nGROUP BY DEC.DEPT_ID, DEC.DEPT_NAME, DEC.EMP_COUNT",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPT_EMPLOYEE_COUNT",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "DEPT_ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "DEPT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMP_COUNT",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "AVG_SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "MV_DEPT_STATS",
+ "definition": "SELECT \n D.ID AS DEPT_ID,\n D.NAME AS DEPT_NAME,\n COUNT(E.ID) AS TOTAL_EMPLOYEES,\n NVL(SUM(E.SALARY), 0) AS TOTAL_PAYROLL,\n NVL(AVG(E.SALARY), 0) AS AVG_SALARY,\n NVL(MAX(E.SALARY), 0) AS MAX_SALARY,\n NVL(MIN(E.SALARY), 0) AS MIN_SALARY\nFROM DEPARTMENTS D\nLEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID\nGROUP BY D.ID, D.NAME\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.MV_DEPT_STATS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "DEPARTMENTS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "EMPLOYEES",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "MV_DEPT_STATS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "DEPARTMENTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "MANAGER_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_MANAGER",
+ "columns": [
+ "MANAGER_ID"
+ ],
+ "referencedTable": "EMPLOYEES",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "EMPLOYEES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "DEPARTMENT_ID",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "SALARY",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_DEPT",
+ "columns": [
+ "DEPARTMENT_ID"
+ ],
+ "referencedTable": "DEPARTMENTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.sql
new file mode 100644
index 0000000000..5b433c3dea
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_complex_view_dependencies.sql
@@ -0,0 +1,35 @@
+CREATE VIEW "DEPT_EMPLOYEE_COUNT" AS SELECT D.ID AS DEPT_ID, D.NAME AS DEPT_NAME, COUNT(E.ID) AS EMP_COUNT
+FROM DEPARTMENTS D
+LEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID
+GROUP BY D.ID, D.NAME;
+CREATE MATERIALIZED VIEW "MV_DEPT_STATS" AS SELECT
+ D.ID AS DEPT_ID,
+ D.NAME AS DEPT_NAME,
+ COUNT(E.ID) AS TOTAL_EMPLOYEES,
+ NVL(SUM(E.SALARY), 0) AS TOTAL_PAYROLL,
+ NVL(AVG(E.SALARY), 0) AS AVG_SALARY,
+ NVL(MAX(E.SALARY), 0) AS MAX_SALARY,
+ NVL(MIN(E.SALARY), 0) AS MIN_SALARY
+FROM DEPARTMENTS D
+LEFT JOIN EMPLOYEES E ON D.ID = E.DEPARTMENT_ID
+GROUP BY D.ID, D.NAME
+;
+COMMENT ON MATERIALIZED VIEW "MV_DEPT_STATS" IS 'snapshot table for snapshot TESTSCHEMA.MV_DEPT_STATS';
+CREATE VIEW "DEPT_SUMMARY" AS SELECT
+ DEC.DEPT_ID,
+ DEC.DEPT_NAME,
+ DEC.EMP_COUNT,
+ NVL(AVG(E.SALARY), 0) AS AVG_SALARY
+FROM DEPT_EMPLOYEE_COUNT DEC
+LEFT JOIN EMPLOYEES E ON DEC.DEPT_ID = E.DEPARTMENT_ID
+GROUP BY DEC.DEPT_ID, DEC.DEPT_NAME, DEC.EMP_COUNT;
+CREATE VIEW "DEPT_MANAGER_SUMMARY" AS SELECT
+ DS.DEPT_ID,
+ DS.DEPT_NAME,
+ DS.EMP_COUNT,
+ DS.AVG_SALARY,
+ M.NAME AS MANAGER_NAME
+FROM DEPT_SUMMARY DS
+JOIN DEPARTMENTS D ON DS.DEPT_ID = D.ID
+LEFT JOIN EMPLOYEES M ON D.MANAGER_ID = M.ID;
+COMMENT ON MATERIALIZED VIEW "MV_DEPT_STATS" IS 'snapshot table for snapshot TESTSCHEMA.MV_DEPT_STATS';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.json
new file mode 100644
index 0000000000..30ccde9b7c
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.json
@@ -0,0 +1,153 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {}
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "POSTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USER_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 3,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTENT",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_AT",
+ "position": 5,
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USER_ID",
+ "expressions": [
+ "\"USER_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_USER",
+ "columns": [
+ "USER_ID"
+ ],
+ "referencedTable": "USERS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ]
+ },
+ {
+ "name": "USERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "USERNAME",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 4,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_USERNAME",
+ "expressions": [
+ "\"USERNAME\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "UK_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.sql
new file mode 100644
index 0000000000..e4807a7987
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_create_tables_with_fk.sql
@@ -0,0 +1,3 @@
+ALTER TABLE "POSTS" DROP CONSTRAINT "FK_USER";
+DROP TABLE "POSTS";
+DROP TABLE "USERS";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.json
new file mode 100644
index 0000000000..2cf84b7329
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.json
@@ -0,0 +1,317 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUTHORS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "EMAIL"
+ ],
+ "unique": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "BOOKS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 2,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "AUTHOR_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ISBN",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_YEAR",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRICE",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(8,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000004",
+ "expressions": [
+ "ISBN"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_BOOKS_AUTHOR",
+ "expressions": [
+ "\"AUTHOR_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_BOOKS_YEAR",
+ "expressions": [
+ "\"PUBLISHED_YEAR\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_AUTHOR_NEW",
+ "columns": [
+ "AUTHOR_ID"
+ ],
+ "referencedTable": "AUTHORS",
+ "referencedColumns": [
+ "ID"
+ ],
+ "onDelete": "CASCADE"
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_TITLE_LENGTH",
+ "expression": "LENGTH(TITLE) \u003e= 3"
+ },
+ {
+ "name": "CHECK_YEAR_EXTENDED",
+ "expression": "PUBLISHED_YEAR \u003e= 1000 AND PUBLISHED_YEAR \u003c= 2030"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUTHORS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "EMAIL"
+ ],
+ "unique": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "BOOKS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TITLE",
+ "position": 2,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "AUTHOR_ID",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "ISBN",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PUBLISHED_YEAR",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRICE",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(8,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "SYS_C0000004",
+ "expressions": [
+ "ISBN"
+ ],
+ "unique": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_BOOKS_AUTHOR",
+ "expressions": [
+ "\"AUTHOR_ID\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_BOOKS_YEAR",
+ "expressions": [
+ "\"PUBLISHED_YEAR\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_AUTHOR",
+ "columns": [
+ "AUTHOR_ID"
+ ],
+ "referencedTable": "AUTHORS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ },
+ {
+ "name": "CHECK_YEAR_VALID",
+ "expression": "PUBLISHED_YEAR \u003e= 1000 AND PUBLISHED_YEAR \u003c= 2100"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.sql
new file mode 100644
index 0000000000..32f603894f
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_and_recreate_constraints.sql
@@ -0,0 +1,7 @@
+ALTER TABLE "BOOKS" DROP CONSTRAINT "FK_AUTHOR";
+ALTER TABLE "BOOKS" DROP CONSTRAINT "CHECK_PRICE_POSITIVE";
+ALTER TABLE "BOOKS" DROP CONSTRAINT "CHECK_YEAR_VALID";
+
+ALTER TABLE "BOOKS" ADD CONSTRAINT "CHECK_TITLE_LENGTH" CHECK (LENGTH(TITLE) >= 3);
+ALTER TABLE "BOOKS" ADD CONSTRAINT "CHECK_YEAR_EXTENDED" CHECK (PUBLISHED_YEAR >= 1000 AND PUBLISHED_YEAR <= 2030);
+ALTER TABLE "BOOKS" ADD CONSTRAINT "FK_AUTHOR_NEW" FOREIGN KEY ("AUTHOR_ID") REFERENCES "AUTHORS" ("ID") ON DELETE CASCADE;
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.json
new file mode 100644
index 0000000000..d4b11dd1b1
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.json
@@ -0,0 +1,160 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SUPPLIER_ID",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SUPPLIER_ID",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_NAME",
+ "expressions": [
+ "\"NAME\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ },
+ {
+ "name": "IDX_PRODUCTS_PRICE",
+ "expressions": [
+ "\"PRICE\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHECK_NAME_LENGTH",
+ "expression": "LENGTH(NAME) \u003e= 3"
+ },
+ {
+ "name": "CHECK_PRICE_POSITIVE",
+ "expression": "PRICE \u003e 0"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.sql
new file mode 100644
index 0000000000..7e946d8d47
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_indexes_and_constraints.sql
@@ -0,0 +1,6 @@
+ALTER TABLE "PRODUCTS" DROP CONSTRAINT "CHECK_NAME_LENGTH";
+ALTER TABLE "PRODUCTS" DROP CONSTRAINT "CHECK_PRICE_POSITIVE";
+DROP INDEX "IDX_PRODUCTS_CATEGORY";
+DROP INDEX "IDX_PRODUCTS_NAME";
+DROP INDEX "IDX_PRODUCTS_PRICE";
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.json
new file mode 100644
index 0000000000..bc08990d30
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.json
@@ -0,0 +1,52 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {}
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SIMPLE_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TRANSACTION_SEQ\".NEXTVAL",
+ "type": "NUMBER"
+ },
+ {
+ "name": "MESSAGE",
+ "position": 2,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "sequences": [
+ {
+ "name": "TRANSACTION_SEQ"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.sql
new file mode 100644
index 0000000000..4c67dd0864
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_sequence.sql
@@ -0,0 +1,2 @@
+DROP TABLE "SIMPLE_LOG";
+DROP SEQUENCE "TRANSACTION_SEQ";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.json
new file mode 100644
index 0000000000..57b20b2789
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.json
@@ -0,0 +1,160 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "SALE_AMOUNT",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 4,
+ "type": "DATE"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "SALES",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "SALE_AMOUNT",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "SALE_DATE",
+ "position": 4,
+ "type": "DATE"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "MONTHLY_SALES",
+ "definition": "SELECT \n EXTRACT(YEAR FROM SALE_DATE) AS YEAR_VAL,\n EXTRACT(MONTH FROM SALE_DATE) AS MONTH_VAL,\n SUM(SALE_AMOUNT) AS TOTAL_SALES\nFROM SALES\nGROUP BY EXTRACT(YEAR FROM SALE_DATE), EXTRACT(MONTH FROM SALE_DATE)",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "SALES",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "YEAR_VAL",
+ "position": 1,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "MONTH_VAL",
+ "position": 2,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL_SALES",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_DISCOUNT",
+ "definition": "FUNCTION CALCULATE_DISCOUNT(AMOUNT NUMBER)\nRETURN NUMBER\nIS\nBEGIN\n RETURN AMOUNT * 0.1;\nEND;"
+ },
+ {
+ "name": "GET_MONTHLY_TOTAL",
+ "definition": "FUNCTION GET_MONTHLY_TOTAL(YEAR_PARAM NUMBER, MONTH_PARAM NUMBER)\nRETURN NUMBER\nIS\n V_TOTAL NUMBER;\nBEGIN\n SELECT NVL(SUM(SALE_AMOUNT), 0) INTO V_TOTAL\n FROM SALES\n WHERE EXTRACT(YEAR FROM SALE_DATE) = YEAR_PARAM\n AND EXTRACT(MONTH FROM SALE_DATE) = MONTH_PARAM;\n \n RETURN V_TOTAL;\nEND;"
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "TOP_PRODUCTS",
+ "definition": "SELECT \n PRODUCT_NAME,\n COUNT(*) AS SALE_COUNT,\n SUM(SALE_AMOUNT) AS TOTAL_REVENUE\nFROM SALES\nGROUP BY PRODUCT_NAME\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.TOP_PRODUCTS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "SALES",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "TOP_PRODUCTS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.sql
new file mode 100644
index 0000000000..f3ad02cb5f
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_drop_views_and_functions.sql
@@ -0,0 +1,4 @@
+DROP FUNCTION "CALCULATE_DISCOUNT";
+DROP FUNCTION "GET_MONTHLY_TOTAL";
+DROP VIEW "MONTHLY_SALES";
+DROP MATERIALIZED VIEW "TOP_PRODUCTS";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.json
new file mode 100644
index 0000000000..a71e191f17
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.json
@@ -0,0 +1,161 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "TEST_COLUMNS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "COL_VARCHAR",
+ "position": 2,
+ "type": "VARCHAR2(200 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_NUMBER",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER(15,3)"
+ },
+ {
+ "name": "COL_DATE",
+ "position": 4,
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "COL_NULLABLE",
+ "position": 5,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_WITH_DEFAULT",
+ "position": 6,
+ "default": "'NEW_DEFAULT'",
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_TIMESTAMP",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "COL_BOOLEAN",
+ "position": 8,
+ "nullable": true,
+ "type": "NUMBER(1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "checkConstraints": [
+ {
+ "name": "CHK_NUMBER_POSITIVE",
+ "expression": "COL_NUMBER \u003e 0"
+ },
+ {
+ "name": "CHK_VARCHAR_LENGTH",
+ "expression": "LENGTH(COL_VARCHAR) \u003e= 5"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "TEST_COLUMNS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "COL_VARCHAR",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_NUMBER",
+ "position": 3,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "COL_DATE",
+ "position": 4,
+ "nullable": true,
+ "type": "DATE"
+ },
+ {
+ "name": "COL_NULLABLE",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_WITH_DEFAULT",
+ "position": 6,
+ "default": "'DEFAULT_VALUE'",
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "COL_CLOB",
+ "position": 7,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.sql
new file mode 100644
index 0000000000..d33be2738c
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_edge_case_column_operations.sql
@@ -0,0 +1,11 @@
+ALTER TABLE "TEST_COLUMNS" DROP COLUMN "COL_CLOB";
+
+ALTER TABLE "TEST_COLUMNS" ADD "COL_TIMESTAMP" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE "TEST_COLUMNS" ADD "COL_BOOLEAN" NUMBER(1);
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_VARCHAR" VARCHAR2(200 BYTE);
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_NUMBER" NUMBER(15,3);
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_NULLABLE" NOT NULL;
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_WITH_DEFAULT" DEFAULT NULL;
+ALTER TABLE "TEST_COLUMNS" MODIFY "COL_WITH_DEFAULT" DEFAULT 'NEW_DEFAULT';
+ALTER TABLE "TEST_COLUMNS" ADD CONSTRAINT "CHK_NUMBER_POSITIVE" CHECK (COL_NUMBER > 0);
+ALTER TABLE "TEST_COLUMNS" ADD CONSTRAINT "CHK_VARCHAR_LENGTH" CHECK (LENGTH(COL_VARCHAR) >= 5);
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.json
new file mode 100644
index 0000000000..e78581b3ed
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.json
@@ -0,0 +1,246 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "INVENTORY",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_CODE",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Updated: Standardized product SKU following new naming convention"
+ },
+ {
+ "name": "STOCK_LEVEL",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Updated: Real-time stock quantity with automated updates"
+ },
+ {
+ "name": "MIN_STOCK",
+ "position": 4,
+ "default": "10",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Updated: Dynamic minimum threshold based on sales velocity"
+ },
+ {
+ "name": "MAX_STOCK",
+ "position": 5,
+ "default": "1000",
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "WAREHOUSE_ID",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "LAST_UPDATED",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)",
+ "comment": "Timestamp of last inventory update or modification"
+ },
+ {
+ "name": "REORDER_POINT",
+ "position": 8,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Calculated reorder point based on lead time and demand"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Updated inventory management system with enhanced tracking capabilities"
+ },
+ {
+ "name": "SUPPLIERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTACT_EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "RATING",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(2,1)",
+ "comment": "Supplier performance rating (1.0 to 5.0 scale)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "INVENTORY",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_CODE",
+ "position": 2,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product identification code"
+ },
+ {
+ "name": "STOCK_LEVEL",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Current stock quantity"
+ },
+ {
+ "name": "MIN_STOCK",
+ "position": 4,
+ "default": "10",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Minimum stock threshold"
+ },
+ {
+ "name": "MAX_STOCK",
+ "position": 5,
+ "default": "1000",
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Maximum stock capacity"
+ },
+ {
+ "name": "WAREHOUSE_ID",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER",
+ "comment": "Warehouse location identifier"
+ },
+ {
+ "name": "LAST_UPDATED",
+ "position": 7,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Initial inventory tracking table"
+ },
+ {
+ "name": "SUPPLIERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CONTACT_EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Primary contact email"
+ },
+ {
+ "name": "RATING",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(2,1)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Supplier information table"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.sql
new file mode 100644
index 0000000000..e0a610d5eb
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_modify_and_drop_comments.sql
@@ -0,0 +1,21 @@
+ALTER TABLE "INVENTORY" ADD "REORDER_POINT" NUMBER DEFAULT 0;
+COMMENT ON TABLE "INVENTORY" IS 'Updated inventory management system with enhanced tracking capabilities';
+COMMENT ON COLUMN "INVENTORY"."PRODUCT_CODE" IS 'Updated: Standardized product SKU following new naming convention';
+COMMENT ON COLUMN "INVENTORY"."STOCK_LEVEL" IS 'Updated: Real-time stock quantity with automated updates';
+COMMENT ON COLUMN "INVENTORY"."MIN_STOCK" IS 'Updated: Dynamic minimum threshold based on sales velocity';
+COMMENT ON COLUMN "INVENTORY"."MAX_STOCK" IS '';
+COMMENT ON COLUMN "INVENTORY"."WAREHOUSE_ID" IS '';
+COMMENT ON COLUMN "INVENTORY"."LAST_UPDATED" IS 'Timestamp of last inventory update or modification';
+COMMENT ON COLUMN "INVENTORY"."REORDER_POINT" IS 'Calculated reorder point based on lead time and demand';
+COMMENT ON COLUMN "INVENTORY"."PRODUCT_CODE" IS 'Updated: Standardized product SKU following new naming convention';
+COMMENT ON COLUMN "INVENTORY"."STOCK_LEVEL" IS 'Updated: Real-time stock quantity with automated updates';
+COMMENT ON COLUMN "INVENTORY"."MIN_STOCK" IS 'Updated: Dynamic minimum threshold based on sales velocity';
+COMMENT ON COLUMN "INVENTORY"."MAX_STOCK" IS '';
+COMMENT ON COLUMN "INVENTORY"."WAREHOUSE_ID" IS '';
+COMMENT ON COLUMN "INVENTORY"."LAST_UPDATED" IS 'Timestamp of last inventory update or modification';
+COMMENT ON COLUMN "INVENTORY"."REORDER_POINT" IS 'Calculated reorder point based on lead time and demand';
+COMMENT ON TABLE "SUPPLIERS" IS '';
+COMMENT ON COLUMN "SUPPLIERS"."CONTACT_EMAIL" IS '';
+COMMENT ON COLUMN "SUPPLIERS"."RATING" IS 'Supplier performance rating (1.0 to 5.0 scale)';
+COMMENT ON COLUMN "SUPPLIERS"."CONTACT_EMAIL" IS '';
+COMMENT ON COLUMN "SUPPLIERS"."RATING" IS 'Supplier performance rating (1.0 to 5.0 scale)';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.json
new file mode 100644
index 0000000000..595f2066cb
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.json
@@ -0,0 +1,125 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "SALES_ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"ORDER_SEQ\".NEXTVAL",
+ "type": "NUMBER"
+ },
+ {
+ "name": "ITEM_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_ITEM",
+ "columns": [
+ "ITEM_ID"
+ ],
+ "referencedTable": "ITEMS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ],
+ "sequences": [
+ {
+ "name": "ORDER_SEQ"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.sql
new file mode 100644
index 0000000000..9004932b64
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_sequences.sql
@@ -0,0 +1,9 @@
+CREATE SEQUENCE "ORDER_SEQ";
+CREATE TABLE "SALES_ORDERS" (
+ "ID" NUMBER DEFAULT "ORDER_SEQ".NEXTVAL NOT NULL,
+ "ITEM_ID" NUMBER NOT NULL,
+ "QUANTITY" NUMBER NOT NULL
+);
+ALTER TABLE "SALES_ORDERS" ADD CONSTRAINT "SYS_C0000002" PRIMARY KEY (ID);
+
+ALTER TABLE "SALES_ORDERS" ADD CONSTRAINT "FK_ITEM" FOREIGN KEY ("ITEM_ID") REFERENCES "ITEMS" ("ID");
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.json
new file mode 100644
index 0000000000..7cdcd51976
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.json
@@ -0,0 +1,164 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUDIT_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TABLE_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OPERATION",
+ "position": 3,
+ "type": "VARCHAR2(10 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OLD_VALUES",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "NEW_VALUES",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TIMESTAMP",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "USER_NAME",
+ "position": 7,
+ "default": "USER",
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_BUSINESS_DAYS",
+ "definition": "FUNCTION CALCULATE_BUSINESS_DAYS(\n P_START_DATE DATE,\n P_END_DATE DATE\n) RETURN NUMBER\nIS\n V_DAYS NUMBER := 0;\n V_CURRENT_DATE DATE := P_START_DATE;\nBEGIN\n WHILE V_CURRENT_DATE \u003c= P_END_DATE LOOP\n -- Skip weekends (Saturday = 7, Sunday = 1)\n IF TO_CHAR(V_CURRENT_DATE, 'D') NOT IN ('1', '7') THEN\n V_DAYS := V_DAYS + 1;\n END IF;\n V_CURRENT_DATE := V_CURRENT_DATE + 1;\n END LOOP;\n \n RETURN V_DAYS;\nEND;"
+ },
+ {
+ "name": "GET_AUDIT_COUNT",
+ "definition": "FUNCTION GET_AUDIT_COUNT(P_TABLE_NAME VARCHAR2) RETURN NUMBER\nIS\n V_COUNT NUMBER;\nBEGIN\n SELECT COUNT(*) INTO V_COUNT\n FROM AUDIT_LOG\n WHERE TABLE_NAME = P_TABLE_NAME;\n \n RETURN V_COUNT;\nEND;"
+ }
+ ],
+ "procedures": [
+ {
+ "name": "LOG_AUDIT",
+ "definition": "PROCEDURE LOG_AUDIT(\n P_TABLE_NAME VARCHAR2,\n P_OPERATION VARCHAR2,\n P_OLD_VALUES CLOB DEFAULT NULL,\n P_NEW_VALUES CLOB DEFAULT NULL\n)\nIS\nBEGIN\n INSERT INTO AUDIT_LOG (TABLE_NAME, OPERATION, OLD_VALUES, NEW_VALUES)\n VALUES (P_TABLE_NAME, P_OPERATION, P_OLD_VALUES, P_NEW_VALUES);\n COMMIT;\nEXCEPTION\n WHEN OTHERS THEN\n ROLLBACK;\n RAISE;\nEND;"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUDIT_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TABLE_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OPERATION",
+ "position": 3,
+ "type": "VARCHAR2(10 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OLD_VALUES",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "NEW_VALUES",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TIMESTAMP",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "USER_NAME",
+ "position": 7,
+ "default": "USER",
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.sql
new file mode 100644
index 0000000000..104a896c6f
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_stored_procedures_and_functions.sql
@@ -0,0 +1,47 @@
+CREATE OR REPLACE FUNCTION CALCULATE_BUSINESS_DAYS(
+ P_START_DATE DATE,
+ P_END_DATE DATE
+) RETURN NUMBER
+IS
+ V_DAYS NUMBER := 0;
+ V_CURRENT_DATE DATE := P_START_DATE;
+BEGIN
+ WHILE V_CURRENT_DATE <= P_END_DATE LOOP
+ -- Skip weekends (Saturday = 7, Sunday = 1)
+ IF TO_CHAR(V_CURRENT_DATE, 'D') NOT IN ('1', '7') THEN
+ V_DAYS := V_DAYS + 1;
+ END IF;
+ V_CURRENT_DATE := V_CURRENT_DATE + 1;
+ END LOOP;
+
+ RETURN V_DAYS;
+END;
+
+CREATE OR REPLACE FUNCTION GET_AUDIT_COUNT(P_TABLE_NAME VARCHAR2) RETURN NUMBER
+IS
+ V_COUNT NUMBER;
+BEGIN
+ SELECT COUNT(*) INTO V_COUNT
+ FROM AUDIT_LOG
+ WHERE TABLE_NAME = P_TABLE_NAME;
+
+ RETURN V_COUNT;
+END;
+
+CREATE OR REPLACE PROCEDURE LOG_AUDIT(
+ P_TABLE_NAME VARCHAR2,
+ P_OPERATION VARCHAR2,
+ P_OLD_VALUES CLOB DEFAULT NULL,
+ P_NEW_VALUES CLOB DEFAULT NULL
+)
+IS
+BEGIN
+ INSERT INTO AUDIT_LOG (TABLE_NAME, OPERATION, OLD_VALUES, NEW_VALUES)
+ VALUES (P_TABLE_NAME, P_OPERATION, P_OLD_VALUES, P_NEW_VALUES);
+ COMMIT;
+EXCEPTION
+ WHEN OTHERS THEN
+ ROLLBACK;
+ RAISE;
+END;
+
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.json
new file mode 100644
index 0000000000..dda769f17c
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.json
@@ -0,0 +1,375 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER",
+ "comment": "Primary key for customer records"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Full name of the customer"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Customer email address (unique)"
+ },
+ {
+ "name": "PHONE",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Contact phone number"
+ },
+ {
+ "name": "ADDRESS",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Full mailing address with multiple lines"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_CUSTOMERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ],
+ "comment": "Customer information and contact details"
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER",
+ "comment": "Unique order identifier"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER",
+ "comment": "Reference to customer who placed the order"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Reference to ordered product"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 4,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE",
+ "comment": "Date when the order was placed"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 5,
+ "type": "NUMBER",
+ "comment": "Number of items ordered"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(12,2)",
+ "comment": "Total order amount including taxes"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "default": "'PENDING'",
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Current order status (PENDING, SHIPPED, DELIVERED, CANCELLED)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Customer orders linking products and customers",
+ "foreignKeys": [
+ {
+ "name": "FK_ORDER_CUSTOMER",
+ "columns": [
+ "CUSTOMER_ID"
+ ],
+ "referencedTable": "CUSTOMERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ },
+ {
+ "name": "FK_ORDER_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER",
+ "comment": "Unique product identifier (auto-generated)"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product name - must be unique and descriptive"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)",
+ "comment": "Product price in USD with 2 decimal places"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Detailed product description with HTML formatting support"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product category for filtering and organization"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)",
+ "comment": "Timestamp when the product was added to catalog"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "comment": "Product catalog table containing all product information"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PHONE",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "ADDRESS",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_CUSTOMERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.sql
new file mode 100644
index 0000000000..93cafc8d18
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_table_and_column_comments.sql
@@ -0,0 +1,45 @@
+CREATE TABLE "ORDERS" (
+ "ID" NUMBER DEFAULT "TESTSCHEMA"."ISEQ$$_0000002".nextval NOT NULL,
+ "CUSTOMER_ID" NUMBER NOT NULL,
+ "PRODUCT_ID" NUMBER NOT NULL,
+ "ORDER_DATE" DATE DEFAULT SYSDATE,
+ "QUANTITY" NUMBER NOT NULL,
+ "TOTAL_AMOUNT" NUMBER(12,2),
+ "STATUS" VARCHAR2(20 BYTE) DEFAULT 'PENDING'
+);
+ALTER TABLE "ORDERS" ADD CONSTRAINT "SYS_C0000002" PRIMARY KEY (ID);
+COMMENT ON TABLE "ORDERS" IS 'Customer orders linking products and customers';
+COMMENT ON COLUMN "ORDERS"."ID" IS 'Unique order identifier';
+COMMENT ON COLUMN "ORDERS"."CUSTOMER_ID" IS 'Reference to customer who placed the order';
+COMMENT ON COLUMN "ORDERS"."PRODUCT_ID" IS 'Reference to ordered product';
+COMMENT ON COLUMN "ORDERS"."ORDER_DATE" IS 'Date when the order was placed';
+COMMENT ON COLUMN "ORDERS"."QUANTITY" IS 'Number of items ordered';
+COMMENT ON COLUMN "ORDERS"."TOTAL_AMOUNT" IS 'Total order amount including taxes';
+COMMENT ON COLUMN "ORDERS"."STATUS" IS 'Current order status (PENDING, SHIPPED, DELIVERED, CANCELLED)';
+
+ALTER TABLE "ORDERS" ADD CONSTRAINT "FK_ORDER_CUSTOMER" FOREIGN KEY ("CUSTOMER_ID") REFERENCES "CUSTOMERS" ("ID");
+ALTER TABLE "ORDERS" ADD CONSTRAINT "FK_ORDER_PRODUCT" FOREIGN KEY ("PRODUCT_ID") REFERENCES "PRODUCTS" ("ID");
+COMMENT ON TABLE "CUSTOMERS" IS 'Customer information and contact details';
+COMMENT ON COLUMN "CUSTOMERS"."ID" IS 'Primary key for customer records';
+COMMENT ON COLUMN "CUSTOMERS"."NAME" IS 'Full name of the customer';
+COMMENT ON COLUMN "CUSTOMERS"."EMAIL" IS 'Customer email address (unique)';
+COMMENT ON COLUMN "CUSTOMERS"."PHONE" IS 'Contact phone number';
+COMMENT ON COLUMN "CUSTOMERS"."ADDRESS" IS 'Full mailing address with multiple lines';
+COMMENT ON COLUMN "CUSTOMERS"."ID" IS 'Primary key for customer records';
+COMMENT ON COLUMN "CUSTOMERS"."NAME" IS 'Full name of the customer';
+COMMENT ON COLUMN "CUSTOMERS"."EMAIL" IS 'Customer email address (unique)';
+COMMENT ON COLUMN "CUSTOMERS"."PHONE" IS 'Contact phone number';
+COMMENT ON COLUMN "CUSTOMERS"."ADDRESS" IS 'Full mailing address with multiple lines';
+COMMENT ON TABLE "PRODUCTS" IS 'Product catalog table containing all product information';
+COMMENT ON COLUMN "PRODUCTS"."ID" IS 'Unique product identifier (auto-generated)';
+COMMENT ON COLUMN "PRODUCTS"."NAME" IS 'Product name - must be unique and descriptive';
+COMMENT ON COLUMN "PRODUCTS"."PRICE" IS 'Product price in USD with 2 decimal places';
+COMMENT ON COLUMN "PRODUCTS"."DESCRIPTION" IS 'Detailed product description with HTML formatting support';
+COMMENT ON COLUMN "PRODUCTS"."CATEGORY" IS 'Product category for filtering and organization';
+COMMENT ON COLUMN "PRODUCTS"."CREATED_AT" IS 'Timestamp when the product was added to catalog';
+COMMENT ON COLUMN "PRODUCTS"."ID" IS 'Unique product identifier (auto-generated)';
+COMMENT ON COLUMN "PRODUCTS"."NAME" IS 'Product name - must be unique and descriptive';
+COMMENT ON COLUMN "PRODUCTS"."PRICE" IS 'Product price in USD with 2 decimal places';
+COMMENT ON COLUMN "PRODUCTS"."DESCRIPTION" IS 'Detailed product description with HTML formatting support';
+COMMENT ON COLUMN "PRODUCTS"."CATEGORY" IS 'Product category for filtering and organization';
+COMMENT ON COLUMN "PRODUCTS"."CREATED_AT" IS 'Timestamp when the product was added to catalog';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.json
new file mode 100644
index 0000000000..9adedffec1
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.json
@@ -0,0 +1,275 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "PRODUCT_INVENTORY",
+ "definition": "SELECT \n P.ID,\n P.NAME,\n P.PRICE,\n P.STOCK,\n NVL(SUM(O.QUANTITY), 0) AS TOTAL_ORDERED\nFROM PRODUCTS P\nLEFT JOIN ORDERS O ON P.ID = O.PRODUCT_ID\nGROUP BY P.ID, P.NAME, P.PRICE, P.STOCK",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "ORDERS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "PRODUCTS",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL_ORDERED",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_ORDER_TOTAL",
+ "definition": "FUNCTION CALCULATE_ORDER_TOTAL(P_PRODUCT_ID NUMBER, P_QUANTITY NUMBER)\nRETURN NUMBER\nIS\n V_PRICE NUMBER(10, 2);\nBEGIN\n SELECT PRICE INTO V_PRICE FROM PRODUCTS WHERE ID = P_PRODUCT_ID;\n RETURN P_QUANTITY * V_PRICE;\nEXCEPTION\n WHEN NO_DATA_FOUND THEN\n RETURN 0;\nEND;"
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "PRODUCT_STATS",
+ "definition": "SELECT \n PRODUCT_ID,\n COUNT(*) AS ORDER_COUNT,\n SUM(QUANTITY) AS TOTAL_QUANTITY,\n SUM(TOTAL) AS TOTAL_REVENUE\nFROM ORDERS\nGROUP BY PRODUCT_ID\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.PRODUCT_STATS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "ORDERS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "PRODUCT_STATS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.sql
new file mode 100644
index 0000000000..5faa18b5b8
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/reverse_views_and_functions.sql
@@ -0,0 +1,31 @@
+CREATE OR REPLACE FUNCTION CALCULATE_ORDER_TOTAL(P_PRODUCT_ID NUMBER, P_QUANTITY NUMBER)
+RETURN NUMBER
+IS
+ V_PRICE NUMBER(10, 2);
+BEGIN
+ SELECT PRICE INTO V_PRICE FROM PRODUCTS WHERE ID = P_PRODUCT_ID;
+ RETURN P_QUANTITY * V_PRICE;
+EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ RETURN 0;
+END;
+
+CREATE VIEW "PRODUCT_INVENTORY" AS SELECT
+ P.ID,
+ P.NAME,
+ P.PRICE,
+ P.STOCK,
+ NVL(SUM(O.QUANTITY), 0) AS TOTAL_ORDERED
+FROM PRODUCTS P
+LEFT JOIN ORDERS O ON P.ID = O.PRODUCT_ID
+GROUP BY P.ID, P.NAME, P.PRICE, P.STOCK;
+CREATE MATERIALIZED VIEW "PRODUCT_STATS" AS SELECT
+ PRODUCT_ID,
+ COUNT(*) AS ORDER_COUNT,
+ SUM(QUANTITY) AS TOTAL_QUANTITY,
+ SUM(TOTAL) AS TOTAL_REVENUE
+FROM ORDERS
+GROUP BY PRODUCT_ID
+;
+COMMENT ON MATERIALIZED VIEW "PRODUCT_STATS" IS 'snapshot table for snapshot TESTSCHEMA.PRODUCT_STATS';
+COMMENT ON MATERIALIZED VIEW "PRODUCT_STATS" IS 'snapshot table for snapshot TESTSCHEMA.PRODUCT_STATS';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/sequences.json b/backend/plugin/schema/oracle/testdata/generate_migration/sequences.json
new file mode 100644
index 0000000000..57324d8b73
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/sequences.json
@@ -0,0 +1,125 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ITEMS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ },
+ {
+ "name": "SALES_ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"ORDER_SEQ\".NEXTVAL",
+ "type": "NUMBER"
+ },
+ {
+ "name": "ITEM_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_ITEM",
+ "columns": [
+ "ITEM_ID"
+ ],
+ "referencedTable": "ITEMS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ }
+ ],
+ "sequences": [
+ {
+ "name": "ORDER_SEQ"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/sequences.sql b/backend/plugin/schema/oracle/testdata/generate_migration/sequences.sql
new file mode 100644
index 0000000000..a8cbdfcf56
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/sequences.sql
@@ -0,0 +1,3 @@
+DROP SEQUENCE "ORDER_SEQ";
+ALTER TABLE "SALES_ORDERS" DROP CONSTRAINT "FK_ITEM";
+DROP TABLE "SALES_ORDERS";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.json
new file mode 100644
index 0000000000..65c0dc8a0a
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.json
@@ -0,0 +1,164 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUDIT_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TABLE_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OPERATION",
+ "position": 3,
+ "type": "VARCHAR2(10 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OLD_VALUES",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "NEW_VALUES",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TIMESTAMP",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "USER_NAME",
+ "position": 7,
+ "default": "USER",
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "AUDIT_LOG",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "TABLE_NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OPERATION",
+ "position": 3,
+ "type": "VARCHAR2(10 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "OLD_VALUES",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "NEW_VALUES",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "TIMESTAMP",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ },
+ {
+ "name": "USER_NAME",
+ "position": 7,
+ "default": "USER",
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_BUSINESS_DAYS",
+ "definition": "FUNCTION CALCULATE_BUSINESS_DAYS(\n P_START_DATE DATE,\n P_END_DATE DATE\n) RETURN NUMBER\nIS\n V_DAYS NUMBER := 0;\n V_CURRENT_DATE DATE := P_START_DATE;\nBEGIN\n WHILE V_CURRENT_DATE \u003c= P_END_DATE LOOP\n -- Skip weekends (Saturday = 7, Sunday = 1)\n IF TO_CHAR(V_CURRENT_DATE, 'D') NOT IN ('1', '7') THEN\n V_DAYS := V_DAYS + 1;\n END IF;\n V_CURRENT_DATE := V_CURRENT_DATE + 1;\n END LOOP;\n \n RETURN V_DAYS;\nEND;"
+ },
+ {
+ "name": "GET_AUDIT_COUNT",
+ "definition": "FUNCTION GET_AUDIT_COUNT(P_TABLE_NAME VARCHAR2) RETURN NUMBER\nIS\n V_COUNT NUMBER;\nBEGIN\n SELECT COUNT(*) INTO V_COUNT\n FROM AUDIT_LOG\n WHERE TABLE_NAME = P_TABLE_NAME;\n \n RETURN V_COUNT;\nEND;"
+ }
+ ],
+ "procedures": [
+ {
+ "name": "LOG_AUDIT",
+ "definition": "PROCEDURE LOG_AUDIT(\n P_TABLE_NAME VARCHAR2,\n P_OPERATION VARCHAR2,\n P_OLD_VALUES CLOB DEFAULT NULL,\n P_NEW_VALUES CLOB DEFAULT NULL\n)\nIS\nBEGIN\n INSERT INTO AUDIT_LOG (TABLE_NAME, OPERATION, OLD_VALUES, NEW_VALUES)\n VALUES (P_TABLE_NAME, P_OPERATION, P_OLD_VALUES, P_NEW_VALUES);\n COMMIT;\nEXCEPTION\n WHEN OTHERS THEN\n ROLLBACK;\n RAISE;\nEND;"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.sql
new file mode 100644
index 0000000000..3dc103be38
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/stored_procedures_and_functions.sql
@@ -0,0 +1,3 @@
+DROP FUNCTION "CALCULATE_BUSINESS_DAYS";
+DROP FUNCTION "GET_AUDIT_COUNT";
+DROP PROCEDURE "LOG_AUDIT";
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.json b/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.json
new file mode 100644
index 0000000000..1b5e4aaa68
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.json
@@ -0,0 +1,375 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PHONE",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "ADDRESS",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_CUSTOMERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "CUSTOMERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER",
+ "comment": "Primary key for customer records"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Full name of the customer"
+ },
+ {
+ "name": "EMAIL",
+ "position": 3,
+ "nullable": true,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Customer email address (unique)"
+ },
+ {
+ "name": "PHONE",
+ "position": 4,
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Contact phone number"
+ },
+ {
+ "name": "ADDRESS",
+ "position": 5,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Full mailing address with multiple lines"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_CUSTOMERS_EMAIL",
+ "expressions": [
+ "\"EMAIL\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "unique": true,
+ "visible": true
+ }
+ ],
+ "comment": "Customer information and contact details"
+ },
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000003\".nextval",
+ "type": "NUMBER",
+ "comment": "Unique order identifier"
+ },
+ {
+ "name": "CUSTOMER_ID",
+ "position": 2,
+ "type": "NUMBER",
+ "comment": "Reference to customer who placed the order"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 3,
+ "type": "NUMBER",
+ "comment": "Reference to ordered product"
+ },
+ {
+ "name": "ORDER_DATE",
+ "position": 4,
+ "default": "SYSDATE",
+ "nullable": true,
+ "type": "DATE",
+ "comment": "Date when the order was placed"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 5,
+ "type": "NUMBER",
+ "comment": "Number of items ordered"
+ },
+ {
+ "name": "TOTAL_AMOUNT",
+ "position": 6,
+ "nullable": true,
+ "type": "NUMBER(12,2)",
+ "comment": "Total order amount including taxes"
+ },
+ {
+ "name": "STATUS",
+ "position": 7,
+ "default": "'PENDING'",
+ "nullable": true,
+ "type": "VARCHAR2(20 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Current order status (PENDING, SHIPPED, DELIVERED, CANCELLED)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000003",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "comment": "Customer orders linking products and customers",
+ "foreignKeys": [
+ {
+ "name": "FK_ORDER_CUSTOMER",
+ "columns": [
+ "CUSTOMER_ID"
+ ],
+ "referencedTable": "CUSTOMERS",
+ "referencedColumns": [
+ "ID"
+ ]
+ },
+ {
+ "name": "FK_ORDER_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER",
+ "comment": "Unique product identifier (auto-generated)"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product name - must be unique and descriptive"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)",
+ "comment": "Product price in USD with 2 decimal places"
+ },
+ {
+ "name": "DESCRIPTION",
+ "position": 4,
+ "nullable": true,
+ "type": "CLOB",
+ "collation": "USING_NLS_COMP",
+ "comment": "Detailed product description with HTML formatting support"
+ },
+ {
+ "name": "CATEGORY",
+ "position": 5,
+ "nullable": true,
+ "type": "VARCHAR2(50 BYTE)",
+ "collation": "USING_NLS_COMP",
+ "comment": "Product category for filtering and organization"
+ },
+ {
+ "name": "CREATED_AT",
+ "position": 6,
+ "default": "CURRENT_TIMESTAMP",
+ "nullable": true,
+ "type": "TIMESTAMP(6)",
+ "comment": "Timestamp when the product was added to catalog"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ },
+ {
+ "name": "IDX_PRODUCTS_CATEGORY",
+ "expressions": [
+ "\"CATEGORY\""
+ ],
+ "descending": [
+ false
+ ],
+ "type": "NORMAL",
+ "visible": true
+ }
+ ],
+ "comment": "Product catalog table containing all product information"
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.sql b/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.sql
new file mode 100644
index 0000000000..bf6ac43e8d
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/table_and_column_comments.sql
@@ -0,0 +1,28 @@
+ALTER TABLE "ORDERS" DROP CONSTRAINT "FK_ORDER_CUSTOMER";
+ALTER TABLE "ORDERS" DROP CONSTRAINT "FK_ORDER_PRODUCT";
+DROP TABLE "ORDERS";
+
+COMMENT ON TABLE "CUSTOMERS" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."ID" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."NAME" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."EMAIL" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."PHONE" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."ADDRESS" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."ID" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."NAME" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."EMAIL" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."PHONE" IS '';
+COMMENT ON COLUMN "CUSTOMERS"."ADDRESS" IS '';
+COMMENT ON TABLE "PRODUCTS" IS '';
+COMMENT ON COLUMN "PRODUCTS"."ID" IS '';
+COMMENT ON COLUMN "PRODUCTS"."NAME" IS '';
+COMMENT ON COLUMN "PRODUCTS"."PRICE" IS '';
+COMMENT ON COLUMN "PRODUCTS"."DESCRIPTION" IS '';
+COMMENT ON COLUMN "PRODUCTS"."CATEGORY" IS '';
+COMMENT ON COLUMN "PRODUCTS"."CREATED_AT" IS '';
+COMMENT ON COLUMN "PRODUCTS"."ID" IS '';
+COMMENT ON COLUMN "PRODUCTS"."NAME" IS '';
+COMMENT ON COLUMN "PRODUCTS"."PRICE" IS '';
+COMMENT ON COLUMN "PRODUCTS"."DESCRIPTION" IS '';
+COMMENT ON COLUMN "PRODUCTS"."CATEGORY" IS '';
+COMMENT ON COLUMN "PRODUCTS"."CREATED_AT" IS '';
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.json b/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.json
new file mode 100644
index 0000000000..959cb4d9ba
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.json
@@ -0,0 +1,275 @@
+{
+ "schemaA": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ },
+ "schemaB": {
+ "name": "TESTSCHEMA",
+ "schemas": [
+ {
+ "tables": [
+ {
+ "name": "ORDERS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000001\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "PRODUCT_ID",
+ "position": 2,
+ "type": "NUMBER"
+ },
+ {
+ "name": "QUANTITY",
+ "position": 3,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER(10,2)"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000001",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ],
+ "foreignKeys": [
+ {
+ "name": "FK_PRODUCT",
+ "columns": [
+ "PRODUCT_ID"
+ ],
+ "referencedTable": "PRODUCTS",
+ "referencedColumns": [
+ "ID"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "PRODUCTS",
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "default": "\"TESTSCHEMA\".\"ISEQ$$_0000002\".nextval",
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "default": "0",
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ],
+ "indexes": [
+ {
+ "name": "SYS_C0000002",
+ "expressions": [
+ "ID"
+ ],
+ "unique": true,
+ "primary": true,
+ "isConstraint": true
+ }
+ ]
+ }
+ ],
+ "views": [
+ {
+ "name": "PRODUCT_INVENTORY",
+ "definition": "SELECT \n P.ID,\n P.NAME,\n P.PRICE,\n P.STOCK,\n NVL(SUM(O.QUANTITY), 0) AS TOTAL_ORDERED\nFROM PRODUCTS P\nLEFT JOIN ORDERS O ON P.ID = O.PRODUCT_ID\nGROUP BY P.ID, P.NAME, P.PRICE, P.STOCK",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "ORDERS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "PRODUCTS",
+ "column": "*"
+ }
+ ],
+ "columns": [
+ {
+ "name": "ID",
+ "position": 1,
+ "type": "NUMBER"
+ },
+ {
+ "name": "NAME",
+ "position": 2,
+ "type": "VARCHAR2(100 BYTE)",
+ "collation": "USING_NLS_COMP"
+ },
+ {
+ "name": "PRICE",
+ "position": 3,
+ "type": "NUMBER(10,2)"
+ },
+ {
+ "name": "STOCK",
+ "position": 4,
+ "nullable": true,
+ "type": "NUMBER"
+ },
+ {
+ "name": "TOTAL_ORDERED",
+ "position": 5,
+ "nullable": true,
+ "type": "NUMBER"
+ }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "CALCULATE_ORDER_TOTAL",
+ "definition": "FUNCTION CALCULATE_ORDER_TOTAL(P_PRODUCT_ID NUMBER, P_QUANTITY NUMBER)\nRETURN NUMBER\nIS\n V_PRICE NUMBER(10, 2);\nBEGIN\n SELECT PRICE INTO V_PRICE FROM PRODUCTS WHERE ID = P_PRODUCT_ID;\n RETURN P_QUANTITY * V_PRICE;\nEXCEPTION\n WHEN NO_DATA_FOUND THEN\n RETURN 0;\nEND;"
+ }
+ ],
+ "materializedViews": [
+ {
+ "name": "PRODUCT_STATS",
+ "definition": "SELECT \n PRODUCT_ID,\n COUNT(*) AS ORDER_COUNT,\n SUM(QUANTITY) AS TOTAL_QUANTITY,\n SUM(TOTAL) AS TOTAL_REVENUE\nFROM ORDERS\nGROUP BY PRODUCT_ID\n",
+ "comment": "snapshot table for snapshot TESTSCHEMA.PRODUCT_STATS",
+ "dependencyColumns": [
+ {
+ "schema": "TESTSCHEMA",
+ "table": "ORDERS",
+ "column": "*"
+ },
+ {
+ "schema": "TESTSCHEMA",
+ "table": "PRODUCT_STATS",
+ "column": "*"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "serviceName": "FREEPDB1"
+ }
+}
diff --git a/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.sql b/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.sql
new file mode 100644
index 0000000000..dec8c01142
--- /dev/null
+++ b/backend/plugin/schema/oracle/testdata/generate_migration/views_and_functions.sql
@@ -0,0 +1,3 @@
+DROP FUNCTION "CALCULATE_ORDER_TOTAL";
+DROP VIEW "PRODUCT_INVENTORY";
+DROP MATERIALIZED VIEW "PRODUCT_STATS";
diff --git a/backend/plugin/schema/oracle/testutil_test.go b/backend/plugin/schema/oracle/testutil_test.go
index 0f3a303aa4..0da8c37adf 100644
--- a/backend/plugin/schema/oracle/testutil_test.go
+++ b/backend/plugin/schema/oracle/testutil_test.go
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"fmt"
+ "slices"
"strings"
"github.com/pkg/errors"
@@ -103,3 +104,146 @@ func executeStatements(ctx context.Context, driver db.Driver, statements string)
return nil
}
+func normalizeMetadataForComparison(metadata *storepb.DatabaseSchemaMetadata) {
+ // Clear database name as it might differ
+ metadata.Name = ""
+
+ // Normalize schemas
+ for _, schema := range metadata.Schemas {
+ // Normalize tables
+ for _, table := range schema.Tables {
+ table.DataSize = 0
+ table.IndexSize = 0
+ table.RowCount = 0
+
+ // Filter out system-generated indexes that reference virtual columns
+ var filteredIndexes []*storepb.IndexMetadata
+ for _, idx := range table.Indexes {
+ // Skip indexes that reference system-generated virtual columns
+ hasVirtualColumn := false
+ for _, expr := range idx.Expressions {
+ if strings.HasPrefix(expr, "SYS_NC") {
+ hasVirtualColumn = true
+ break
+ }
+ }
+ if !hasVirtualColumn {
+ filteredIndexes = append(filteredIndexes, idx)
+ }
+ }
+ table.Indexes = filteredIndexes
+
+ // Sort columns by name for consistent comparison
+ sortColumnsByName(table.Columns)
+
+ // Sort indexes by name
+ sortIndexesByName(table.Indexes)
+
+ // Sort foreign keys by name
+ sortForeignKeysByName(table.ForeignKeys)
+
+ // Sort check constraints by name
+ sortCheckConstraintsByName(table.CheckConstraints)
+ }
+
+ // Filter out system-generated sequences
+ var filteredSequences []*storepb.SequenceMetadata
+ for _, seq := range schema.Sequences {
+ if !strings.HasPrefix(seq.Name, "ISEQ$$_") {
+ filteredSequences = append(filteredSequences, seq)
+ }
+ }
+ schema.Sequences = filteredSequences
+
+ // Sort all collections for consistent comparison
+ sortTablesByName(schema.Tables)
+ sortViewsByName(schema.Views)
+ sortMaterializedViewsByName(schema.MaterializedViews)
+ sortFunctionsByName(schema.Functions)
+ sortSequencesByName(schema.Sequences)
+ }
+
+ // Sort schemas by name
+ sortSchemasByName(metadata.Schemas)
+
+ // Sort extensions by name
+ sortExtensionsByName(metadata.Extensions)
+}
+
+// Sorting helper functions
+func sortSchemasByName(schemas []*storepb.SchemaMetadata) {
+ slices.SortFunc(schemas, func(a, b *storepb.SchemaMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortTablesByName(tables []*storepb.TableMetadata) {
+ slices.SortFunc(tables, func(a, b *storepb.TableMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortColumnsByName(columns []*storepb.ColumnMetadata) {
+ slices.SortFunc(columns, func(a, b *storepb.ColumnMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortIndexesByName(indexes []*storepb.IndexMetadata) {
+ slices.SortFunc(indexes, func(a, b *storepb.IndexMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortForeignKeysByName(fks []*storepb.ForeignKeyMetadata) {
+ slices.SortFunc(fks, func(a, b *storepb.ForeignKeyMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortCheckConstraintsByName(checks []*storepb.CheckConstraintMetadata) {
+ slices.SortFunc(checks, func(a, b *storepb.CheckConstraintMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+// normalizeColumnPositions sets all column positions to 0 to ignore position differences during comparison
+func normalizeColumnPositions(metadata *storepb.DatabaseSchemaMetadata) {
+ for _, schema := range metadata.Schemas {
+ for _, table := range schema.Tables {
+ for _, column := range table.Columns {
+ column.Position = 0
+ }
+ }
+ }
+}
+
+func sortViewsByName(views []*storepb.ViewMetadata) {
+ slices.SortFunc(views, func(a, b *storepb.ViewMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortMaterializedViewsByName(mvs []*storepb.MaterializedViewMetadata) {
+ slices.SortFunc(mvs, func(a, b *storepb.MaterializedViewMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortFunctionsByName(functions []*storepb.FunctionMetadata) {
+ slices.SortFunc(functions, func(a, b *storepb.FunctionMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortSequencesByName(sequences []*storepb.SequenceMetadata) {
+ slices.SortFunc(sequences, func(a, b *storepb.SequenceMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
+func sortExtensionsByName(extensions []*storepb.ExtensionMetadata) {
+ slices.SortFunc(extensions, func(a, b *storepb.ExtensionMetadata) int {
+ return strings.Compare(a.Name, b.Name)
+ })
+}