-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
11 changed files
with
355 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Continuous Integration | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
ci-python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
- name: Setup a local virtual environment (if no poetry.toml file) | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Define a cache for the virtual environment based on the dependencies lock file | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
- name: Install the project dependencies | ||
run: poetry install | ||
- name: Run lint | ||
run: poetry run ruff --output-format=github . | ||
|
||
integration-tests: | ||
strategy: | ||
matrix: | ||
dialect: [ mysql, postgresql, sqlite ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
- name: Setup a local virtual environment (if no poetry.toml file) | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Define a cache for the virtual environment based on the dependencies lock file | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
- name: Install the project dependencies | ||
run: poetry install | ||
- name: Install atlas | ||
uses: ariga/setup-atlas@master | ||
- name: Run Test as Standalone | ||
working-directory: ./tests | ||
run: | | ||
atlas migrate diff --env django --var dialect=${{ matrix.dialect }} | ||
- name: Verify migrations generated | ||
working-directory: ./tests | ||
run: | | ||
status=$(git status . --porcelain) | ||
if [ -n "$status" ]; then | ||
echo "you need to run 'atlas migrate diff --env django and commit the changes" | ||
echo "$status" | ||
git --no-pager diff | ||
exit 1 | ||
fi |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,35 @@ | ||
variable "dialect" { | ||
type = string | ||
} | ||
|
||
locals { | ||
dev_url = { | ||
mysql = "docker://mysql/8/dev" | ||
postgresql = "docker://postgres/15" | ||
sqlite = "sqlite://?mode=memory&_fk=1" | ||
}[var.dialect] | ||
} | ||
|
||
data "external_schema" "django" { | ||
program = [ | ||
"poetry", | ||
"run", | ||
"python3", | ||
"../manage.py", | ||
"atlas-provider-django", | ||
"--dialect", var.dialect, // mysql | postgresql | sqlite | ||
] | ||
} | ||
|
||
env "django" { | ||
src = data.external_schema.django.url | ||
dev = local.dev_url | ||
migration { | ||
dir = "file://migrations/${var.dialect}" | ||
} | ||
format { | ||
migrate { | ||
diff = "{{ 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,38 @@ | ||
-- Create "app1_musician" table | ||
CREATE TABLE `app1_musician` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`first_name` varchar(50) NOT NULL, | ||
`last_name` varchar(50) NOT NULL, | ||
`instrument` varchar(100) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "app1_album" table | ||
CREATE TABLE `app1_album` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`name` varchar(100) NOT NULL, | ||
`release_date` date NOT NULL, | ||
`num_stars` int NOT NULL, | ||
`artist_id` bigint NOT NULL, | ||
PRIMARY KEY (`id`), | ||
INDEX `app1_album_artist_id_aed0987a_fk_app1_musician_id` (`artist_id`), | ||
CONSTRAINT `app1_album_artist_id_aed0987a_fk_app1_musician_id` FOREIGN KEY (`artist_id`) REFERENCES `app1_musician` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "app2_user" table | ||
CREATE TABLE `app2_user` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`first_name` varchar(50) NOT NULL, | ||
`last_name` varchar(50) NULL, | ||
`roll` varchar(100) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "app2_blog" table | ||
CREATE TABLE `app2_blog` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`name` varchar(100) NOT NULL, | ||
`created_at` date NOT NULL, | ||
`num_stars` int NOT NULL, | ||
`author_id` bigint NOT NULL, | ||
PRIMARY KEY (`id`), | ||
INDEX `app2_blog_author_id_1675e606_fk_app2_user_id` (`author_id`), | ||
CONSTRAINT `app2_blog_author_id_1675e606_fk_app2_user_id` FOREIGN KEY (`author_id`) REFERENCES `app2_user` (`id`) 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:t+fHYX8aCiiNQ7IoDKRSIdnAeO9Mp7o6Eug9hhCCTTE= | ||
20240123150434.sql h1:wZOaDDiz5ov9fn+bBctKy0/HoDZ4QL6VTzk58TialGg= |
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,40 @@ | ||
-- Create "app1_musician" table | ||
CREATE TABLE "public"."app1_musician" ( | ||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"first_name" character varying(50) NOT NULL, | ||
"last_name" character varying(50) NOT NULL, | ||
"instrument" character varying(100) NOT NULL, | ||
PRIMARY KEY ("id") | ||
); | ||
-- Create "app1_album" table | ||
CREATE TABLE "public"."app1_album" ( | ||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"name" character varying(100) NOT NULL, | ||
"release_date" date NOT NULL, | ||
"num_stars" integer NOT NULL, | ||
"artist_id" bigint NOT NULL, | ||
PRIMARY KEY ("id"), | ||
CONSTRAINT "app1_album_artist_id_aed0987a_fk_app1_musician_id" FOREIGN KEY ("artist_id") REFERENCES "public"."app1_musician" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "app1_album_artist_id_aed0987a" to table: "app1_album" | ||
CREATE INDEX "app1_album_artist_id_aed0987a" ON "public"."app1_album" ("artist_id"); | ||
-- Create "app2_user" table | ||
CREATE TABLE "public"."app2_user" ( | ||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"first_name" character varying(50) NOT NULL, | ||
"last_name" character varying(50) NULL, | ||
"roll" character varying(100) NOT NULL, | ||
PRIMARY KEY ("id") | ||
); | ||
-- Create "app2_blog" table | ||
CREATE TABLE "public"."app2_blog" ( | ||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
"name" character varying(100) NOT NULL, | ||
"created_at" date NOT NULL, | ||
"num_stars" integer NOT NULL, | ||
"author_id" bigint NOT NULL, | ||
PRIMARY KEY ("id"), | ||
CONSTRAINT "app2_blog_author_id_1675e606_fk_app2_user_id" FOREIGN KEY ("author_id") REFERENCES "public"."app2_user" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "app2_blog_author_id_1675e606" to table: "app2_blog" | ||
CREATE INDEX "app2_blog_author_id_1675e606" ON "public"."app2_blog" ("author_id"); |
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:wPrdpJIc9fRclW3cMGAqDMqK22dhVkEahLLae2v2Jp4= | ||
20240123150442.sql h1:OssKCxrsi6AnIM5iRKN/lrbHEzgehNTrR0t+AIefm1I= |
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,36 @@ | ||
-- Create "app1_musician" table | ||
CREATE TABLE `app1_musician` ( | ||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`first_name` varchar NOT NULL, | ||
`last_name` varchar NOT NULL, | ||
`instrument` varchar NOT NULL | ||
); | ||
-- Create "app1_album" table | ||
CREATE TABLE `app1_album` ( | ||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`name` varchar NOT NULL, | ||
`release_date` date NOT NULL, | ||
`num_stars` integer NOT NULL, | ||
`artist_id` bigint NOT NULL, | ||
CONSTRAINT `0` FOREIGN KEY (`artist_id`) REFERENCES `app1_musician` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "app1_album_artist_id_aed0987a" to table: "app1_album" | ||
CREATE INDEX `app1_album_artist_id_aed0987a` ON `app1_album` (`artist_id`); | ||
-- Create "app2_user" table | ||
CREATE TABLE `app2_user` ( | ||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`first_name` varchar NOT NULL, | ||
`last_name` varchar NULL, | ||
`roll` varchar NOT NULL | ||
); | ||
-- Create "app2_blog" table | ||
CREATE TABLE `app2_blog` ( | ||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`name` varchar NOT NULL, | ||
`created_at` date NOT NULL, | ||
`num_stars` integer NOT NULL, | ||
`author_id` bigint NOT NULL, | ||
CONSTRAINT `0` FOREIGN KEY (`author_id`) REFERENCES `app2_user` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION | ||
); | ||
-- Create index "app2_blog_author_id_1675e606" to table: "app2_blog" | ||
CREATE INDEX `app2_blog_author_id_1675e606` ON `app2_blog` (`author_id`); |
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:BH7VCgohPrXE2+BAyinbXWinObUasKWvewdQX0rUxJ4= | ||
20240123150447.sql h1:dvS9iDdf9wRJYX8t883ehkjEuXqmkvbOIYE+3x0tmlg= |