-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f75c4
commit 93df070
Showing
10 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
variable "dialect" { | ||
type = string | ||
} | ||
|
||
locals { | ||
dev_url = { | ||
mysql = "docker://mysql/8/dev" | ||
postgres = "docker://postgres/15" | ||
sqlserver = "docker://sqlserver/2022-latest" | ||
sqlite = "sqlite://file::memory:?cache=shared" | ||
}[var.dialect] | ||
} | ||
|
||
data "external_schema" "ef" { | ||
program = [ | ||
"dotnet", | ||
"atlas-ef", | ||
"--", var.dialect, | ||
] | ||
} | ||
|
||
env "ef" { | ||
src = data.external_schema.ef.url | ||
dev = local.dev_url | ||
migration { | ||
dir = "file://migrations/${var.dialect}" | ||
} | ||
format { | ||
migrate { | ||
diff = "{{ sql . \" \" }}" | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Atlas.Provider.Demo/migrations/mysql/20240801062628.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Create "Blogs" table | ||
CREATE TABLE `Blogs` ( | ||
`BlogId` int NOT NULL AUTO_INCREMENT, | ||
`Url` varchar(200) NOT NULL, | ||
`Rating` decimal(5,2) NOT NULL, | ||
`Title` longtext NOT NULL, | ||
`Content` longtext NOT NULL, | ||
`Author` varchar(200) NOT NULL DEFAULT "Anonymous", | ||
PRIMARY KEY (`BlogId`), | ||
UNIQUE INDEX `AK_Blogs_Url` (`Url`) | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "Post" table | ||
CREATE TABLE `Post` ( | ||
`PostId` int NOT NULL AUTO_INCREMENT, | ||
`Title` longtext NOT NULL, | ||
`Content` longtext NOT NULL, | ||
`BlogUrl` varchar(200) NULL, | ||
PRIMARY KEY (`PostId`), | ||
INDEX `IX_Post_BlogUrl` (`BlogUrl`), | ||
CONSTRAINT `FK_Post_Blogs_BlogUrl` FOREIGN KEY (`BlogUrl`) REFERENCES `Blogs` (`Url`) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1:5fH6Rflvu1KK+Ic9C3Gmh6xB+7/BGljfGnQRQxQJlEE= | ||
20240801062628.sql h1:Fe+/2wnZoHlL8dkd4M+AUQ5HDN8MWOqO+HYRiKNgVkg= |
22 changes: 22 additions & 0 deletions
22
src/Atlas.Provider.Demo/migrations/postgres/20240801063041.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Create "Blogs" table | ||
CREATE TABLE "public"."Blogs" ( | ||
"BlogId" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"Url" character varying(200) NOT NULL, | ||
"Rating" numeric(5,2) NOT NULL, | ||
"Title" text NOT NULL, | ||
"Content" text NOT NULL, | ||
"Author" character varying(200) NOT NULL DEFAULT 'Anonymous', | ||
PRIMARY KEY ("BlogId"), | ||
CONSTRAINT "AK_Blogs_Url" UNIQUE ("Url") | ||
); | ||
-- Create "Post" table | ||
CREATE TABLE "public"."Post" ( | ||
"PostId" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"Title" text NOT NULL, | ||
"Content" text NOT NULL, | ||
"BlogUrl" character varying(200) NULL, | ||
PRIMARY KEY ("PostId"), | ||
CONSTRAINT "FK_Post_Blogs_BlogUrl" FOREIGN KEY ("BlogUrl") REFERENCES "public"."Blogs" ("Url") ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "IX_Post_BlogUrl" to table: "Post" | ||
CREATE INDEX "IX_Post_BlogUrl" ON "public"."Post" ("BlogUrl"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1:RrEgzMnaMIrwlUtSCD34giSU1V37NUy1RCt+3sGsULg= | ||
20240801063041.sql h1:TeGzHV6ca+FPLdTm5X4jiMyXCui1YzmSjKKPtxorAi0= |
21 changes: 21 additions & 0 deletions
21
src/Atlas.Provider.Demo/migrations/sqlite/20240801062611.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Create "Blogs" table | ||
CREATE TABLE `Blogs` ( | ||
`BlogId` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`Url` varchar NOT NULL, | ||
`Rating` decimal NOT NULL, | ||
`Title` text NOT NULL, | ||
`Content` text NOT NULL, | ||
`Author` text NOT NULL DEFAULT 'Anonymous' | ||
); | ||
-- Create index "Blogs_Url" to table: "Blogs" | ||
CREATE UNIQUE INDEX `Blogs_Url` ON `Blogs` (`Url`); | ||
-- Create "Post" table | ||
CREATE TABLE `Post` ( | ||
`PostId` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`Title` text NOT NULL, | ||
`Content` text NOT NULL, | ||
`BlogUrl` varchar NULL, | ||
CONSTRAINT `FK_Post_Blogs_BlogUrl` FOREIGN KEY (`BlogUrl`) REFERENCES `Blogs` (`Url`) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "IX_Post_BlogUrl" to table: "Post" | ||
CREATE INDEX `IX_Post_BlogUrl` ON `Post` (`BlogUrl`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1:FKhd6jUc7x8NeX2WnSlOWvU5WNPx+Kwk9lEN55FmWP4= | ||
20240801062611.sql h1:Znct9We6Htoro7hiw4Ax77hxq+Uh9A1Cib8i1n6Lr3s= |
24 changes: 24 additions & 0 deletions
24
src/Atlas.Provider.Demo/migrations/sqlserver/20240801063009.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Create "Blogs" table | ||
CREATE TABLE [Blogs] ( | ||
[BlogId] int IDENTITY (1, 1) NOT NULL, | ||
[Url] varchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
[Rating] decimal(5,2) NOT NULL, | ||
[Title] nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
[Content] nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
[Author] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS CONSTRAINT [DF__Blogs__Author__21D600EE] DEFAULT N'Anonymous' NOT NULL, | ||
CONSTRAINT [PK_Blogs] PRIMARY KEY CLUSTERED ([BlogId] ASC) | ||
); | ||
-- Create index "AK_Blogs_Url" to table: "Blogs" | ||
CREATE UNIQUE NONCLUSTERED INDEX [AK_Blogs_Url] ON [Blogs] ([Url] ASC); | ||
-- Create "Post" table | ||
CREATE TABLE [Post] ( | ||
[PostId] int IDENTITY (1, 1) NOT NULL, | ||
[Title] nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
[Content] nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
[BlogUrl] varchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
CONSTRAINT [PK_Post] PRIMARY KEY CLUSTERED ([PostId] ASC), | ||
|
||
CONSTRAINT [FK_Post_Blogs_BlogUrl] FOREIGN KEY ([BlogUrl]) REFERENCES [Blogs] ([Url]) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "IX_Post_BlogUrl" to table: "Post" | ||
CREATE NONCLUSTERED INDEX [IX_Post_BlogUrl] ON [Post] ([BlogUrl] ASC); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1:zyMNceRFu+qrN01W99yPXWFCSWJQYv2LKfa3VV8TVoU= | ||
20240801063009.sql h1:wB+DJtwaX6nTqMV0QjYuXZcjqP7GmgeAv7tzn/baYME= |