Repository: schemahero/schemahero (go)

Issue:
Cassandra support appears broken
On a fresh schemahero install of v0.13.8, I'm noticing an error in the controller pod for my cassandra database:
```
manager {"level":"error","msg":"unable to deploy table to connection of different type"}
```

The following are my database and table definitions:
```yaml
---
# https://schemahero.io/docs/connecting-databases/creating-db-resource/

apiVersion: databases.schemahero.io/v1alpha4
kind: Database
metadata:
  name: cassandra-testdb
spec:
  connection:
    cassandra:
      hosts: [ ... ] # omitted
      keyspace:
        valueFrom:
          secretKeyRef:
            name: db-credentials-schema-hero-example-secret
            key: /example/keyspace
      username:
        valueFrom:
          secretKeyRef:
            name: db-credentials-schema-hero-example-secret
            key: /example/db-username
      password:
        valueFrom:
          secretKeyRef:
            name: db-credentials-schema-hero-example-secret
            key: /example/db-password

---
apiVersion: schemas.schemahero.io/v1alpha4
kind: Table
metadata:
  name: players
spec:
  database: cassandra-testdb
  name: players
  schema:
    cassandra:
      primaryKey:
        - [id]
      columns:
        - name: id
          type: varchar
```

Reading the source code, I believe this is where the error is coming from:
https://github.com/schemahero/schemahero/blob/fa83f6214bea133a4d0947423d68f8adf6630a6a/pkg/controller/table/reconcile_table.go#L61-L65

and the failing conditional is driven by this function which appears to lack cassandra support:
https://github.com/schemahero/schemahero/blob/fa83f6214bea133a4d0947423d68f8adf6630a6a/pkg/controller/table/reconcile_table.go#L141-L157

I'm new to schemahero and just exploring its capabilities. Please let me know if there's anything that I've overlooked, and thanks for the great work on this tool otherwise!

Pull request description:
Add Cassandra to db type check
Fixes #874

Patch:
diff --git a/pkg/controller/table/reconcile_table.go b/pkg/controller/table/reconcile_table.go
index 2d98a188..43b4bf99 100644
--- a/pkg/controller/table/reconcile_table.go
+++ b/pkg/controller/table/reconcile_table.go
@@ -151,6 +151,8 @@ func checkDatabaseTypeMatches(connection *databasesv1alpha4.DatabaseConnection,
 		return tableSchema.TimescaleDB != nil
 	} else if connection.SQLite != nil {
 		return tableSchema.SQLite != nil
+	} else if connection.Cassandra != nil {
+		return tableSchema.Cassandra != nil
 	}
 
 	return false


Test patch:
diff --git a/pkg/controller/table/reconcile_table_test.go b/pkg/controller/table/reconcile_table_test.go
index 8cc1452c..9d9614c2 100644
--- a/pkg/controller/table/reconcile_table_test.go
+++ b/pkg/controller/table/reconcile_table_test.go
@@ -85,6 +85,18 @@ func Test_checkDatabaseTypeMatches(t *testing.T) {
 			},
 			expect: true,
 		},
+		{
+			name: "is cassandra",
+			connection: databasesv1alpha4.DatabaseConnection{
+				Cassandra: &databasesv1alpha4.CassandraConnection{
+					Hosts: []string{"test"},
+				},
+			},
+			tableSchema: schemasv1alpha4.TableSchema{
+				Cassandra: &schemasv1alpha4.CassandraTableSchema{},
+			},
+			expect: true,
+		},
 	}
 
 	for _, test := range tests {