ClickHouse / ClickHouse/ClickHouse.EntityFrameworkCore

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

Đang mở
#22 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
23
Fork
7
Merge trung bình
14 ngày 3 giờ
Pull request đã merge (30 ngày)
1

Mô tả

### 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);
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by tracing the provider's EFCore migration handling for EnsureSchema and CreateTable, using the migration and SQL examples in the issue as the expected behavior. Confirm how schema-qualified tables and ClickHouse engine annotations are translated. Done means EnsureSchema produces CREATE DATABASE and the table migration produces valid schema-qualified ClickHouse SQL.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, sql
Lĩnh vực
databases
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.