When importing the following SQL:
CREATE TABLE "clients" (
"id" UUID DEFAULT gen_random_uuid () NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL
)
CREATE TABLE "users" (
"id" UUID DEFAULT gen_random_uuid () NOT NULL PRIMARY KEY,
"email" varchar(254) NOT NULL UNIQUE
)
CREATE TABLE "users_clients" (
"user_id" UUID NOT NULL,
"client_id" UUID NOT NULL,
CONSTRAINT "fk_users_clients_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id"),
CONSTRAINT "fk_users_clients_client_id" FOREIGN KEY ("client_id") REFERENCES "clients" ("id")
)
The following DBML is generated:
Table "clients" {
"id" UUID [pk, not null, default: `gen_random_uuid()`]
"name" TEXT [not null]
}
Table "users" {
"id" UUID [pk, not null, default: `gen_random_uuid()`]
"email" varchar(254) [unique, not null]
}
Table "users_clients" {
"user_id" UUID [not null]
"client_id" UUID [not null]
}
Ref "fk_users_clients_user_id":"users"."id" < "users_clients"."user_id"
Ref "fk_users_clients_client_id":"clients"."id" < "users_clients"."client_id"
Since many-to-many relations are supported, despite of the fact that I’ll loose the naming of the constraints, I would like the system to generate the following DBML:
Table "clients" {
"id" UUID [pk, not null, default: `gen_random_uuid()`]
"name" TEXT [not null]
}
Table "users" {
"id" UUID [pk, not null, default: `gen_random_uuid()`]
"email" varchar(254) [unique, not null]
}
Ref "users_clients": "users"."id" <> "clients"."id"
Since not everyone might like this change, it would be good to have it as an option in the SQL-importer.