ClickHouse / ClickHouse/ClickHouse.EntityFrameworkCore

Feature Request: Add Support for EFCore Schemas by Treating Them as Databases

Ouverte
#22 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C#
Étoiles
23
Forks
7
Merge moyen
14 j 3 h
PR mergées (30 j)
1

Description

### Feature Request

EFCore Entity Schemas can be treated like Clickhouse Databases to make EFCore output valid migrations.
In this feature request I propose a change to how Schemas are handled. I will be submitting a pull request along with my feature request.

### Current behavior

Defining an EFCore Entity Configuration such that:

```
e.ToTable("my_table", "my_schema", table =>
{
table.HasMergeTreeEngine()
.WithOrderBy("Timestamp")
.WithPartitionBy("toYear(Timestamp)");
});

e.Property(x => x.Timestamp)
.HasColumnType("Date")
.HasColumnName("Timestamp");
e.Property(x => x.MyString)
.HasColumnType("String")
.HasColumnName("MyString");
e.HasNoKey();
```

and using that entity configuration in an EFCore migration produces the following migration code:

```
migrationBuilder.EnsureSchema(
name: "my_schema");

migrationBuilder.CreateTable(
name: "my_table",
schema: "my_schema",
columns: table => new
{
Timestamp = table.Column(type: "Date32", nullable: false)
},
constraints: table =>
{
})
.Annotation("ClickHouse:Engine", "MergeTree")
.Annotation("ClickHouse:OrderBy", new[] { "Timestamp" })
.Annotation("ClickHouse:PartitionBy", new[] { "toYear(Timestamp)" });

```

Which fails on the ensure schema operation, saying schemas are not supported. This makes it difficult define database structure in EFCore.

### Expected behavior

```
// C# EFCore Migration
migrationBuilder.EnsureSchema(
name: "pre_aggregates");

migrationBuilder.CreateTable(
name: "my_table",
schema: "my_schema",
columns: table => new
{
Timestamp = table.Column(type: "Date32", nullable: false)
MyString = table.Column(type: "String", nullable: false),

},
constraints: table =>
{
})
.Annotation("ClickHouse:Engine", "MergeTree")
.Annotation("ClickHouse:OrderBy", new[] { "Timestamp" })
.Annotation("ClickHouse:PartitionBy", new[] { "toYear(Timestamp)" });
```

// Should translate to:
```
CREATE DATABASE my_schema;

CREATE TABLE `my_schema`.`my_table` (
`Timestamp` Date32,
`MyString` String
)
ENGINE = MergeTree()
ORDER BY (`Timestamp`)
PARTITION BY toYear(Timestamp);
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par suivre le traitement des migrations EFCore du fournisseur pour EnsureSchema et CreateTable, en utilisant les exemples de migration et de SQL de l’issue comme comportement attendu. Confirmez comment les tables qualifiées par un schéma et les annotations de moteur ClickHouse sont traduites. C’est terminé lorsque EnsureSchema produit CREATE DATABASE et que la migration de table produit du SQL ClickHouse valide avec un schéma qualifié.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp, sql
Domaine
databases
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.