Generate SQL migration from Entity defenitions. #325
-
Is there any plans to provide schema generation from entities like in Hibernate / GORM? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @markusgod, welcome! Yes, you can use |
Beta Was this translation helpful? Give feedback.
-
Thanks! Will it create also referenced entities and foreign key constraints? I'm also can't find in the docs how to specify default value (I found in the TableCreateStatement example, but it is not clear how to specify all of this from enity). Here example of what ideally would be nice to be able to generate. CREATE TABLE "users" (
"id" uuid PRIMARY KEY DEFAULT (gen_random_uuid()),
"name" text NOT NULL,
"password" text NOT NULL,
"email" text NOT NULL
);
CREATE TABLE "projects" (
"id" uuid PRIMARY KEY,
"name" text NOT NULL,
"description" text NOT NULL,
"owner" uuid NOT NULL
);
ALTER TABLE "projects" ADD FOREIGN KEY ("owner") REFERENCES "users" ("id"); |
Beta Was this translation helpful? Give feedback.
Hi @markusgod, welcome! Yes, you can use
Schema::create_table_from_entity
.https://www.sea-ql.org/SeaORM/docs/write-test/sqlite#setup-database-schema