-
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
Showing
5 changed files
with
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Setup Atlas | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup Atlas | ||
uses: ariga/setup-atlas@v0 | ||
with: | ||
token: ${{ secrets.ATLAS_PUBLIC_TENANT_TOKEN }} |
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,12 @@ | ||
env "local" { | ||
src = "file://inventory/schema.hcl" | ||
dev = "docker://mysql/8/default" | ||
migration { | ||
dir = "file://inventory/migrations" | ||
} | ||
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,28 @@ | ||
-- Create "categories" table | ||
CREATE TABLE `categories` ( | ||
`category_id` int NOT NULL AUTO_INCREMENT, | ||
`name` varchar(255) NOT NULL, | ||
`description` text NULL, | ||
PRIMARY KEY (`category_id`) | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "suppliers" table | ||
CREATE TABLE `suppliers` ( | ||
`supplier_id` int NOT NULL AUTO_INCREMENT, | ||
`name` varchar(255) NOT NULL, | ||
`contact_info` text NULL, | ||
PRIMARY KEY (`supplier_id`) | ||
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | ||
-- Create "products" table | ||
CREATE TABLE `products` ( | ||
`product_id` int NOT NULL AUTO_INCREMENT, | ||
`name` varchar(255) NOT NULL, | ||
`category_id` int NULL, | ||
`supplier_id` int NULL, | ||
`price` decimal(10,2) NOT NULL, | ||
`description` text NULL, | ||
PRIMARY KEY (`product_id`), | ||
INDEX `category_id` (`category_id`), | ||
INDEX `supplier_id` (`supplier_id`), | ||
CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`category_id`) ON UPDATE NO ACTION ON DELETE NO ACTION, | ||
CONSTRAINT `products_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_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:fo2R2MvvR2SDqpcg3lMGjPvOwppIJ3AIR7rtGh5zPpU= | ||
20240307092728.sql h1:BEXRAbglZQlUqXHRy4fvsEVsu7FlSfKcJ/JAkH2XgMY= |
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,92 @@ | ||
table "categories" { | ||
schema = schema.default | ||
column "category_id" { | ||
null = false | ||
type = int | ||
auto_increment = true | ||
} | ||
column "name" { | ||
null = false | ||
type = varchar(255) | ||
} | ||
column "description" { | ||
null = true | ||
type = text | ||
} | ||
primary_key { | ||
columns = [column.category_id] | ||
} | ||
} | ||
table "products" { | ||
schema = schema.default | ||
column "product_id" { | ||
null = false | ||
type = int | ||
auto_increment = true | ||
} | ||
column "name" { | ||
null = false | ||
type = varchar(255) | ||
} | ||
column "category_id" { | ||
null = true | ||
type = int | ||
} | ||
column "supplier_id" { | ||
null = true | ||
type = int | ||
} | ||
column "price" { | ||
null = false | ||
type = decimal(10,2) | ||
unsigned = false | ||
} | ||
column "description" { | ||
null = true | ||
type = text | ||
} | ||
primary_key { | ||
columns = [column.product_id] | ||
} | ||
foreign_key "products_ibfk_1" { | ||
columns = [column.category_id] | ||
ref_columns = [table.categories.column.category_id] | ||
on_update = NO_ACTION | ||
on_delete = NO_ACTION | ||
} | ||
foreign_key "products_ibfk_2" { | ||
columns = [column.supplier_id] | ||
ref_columns = [table.suppliers.column.supplier_id] | ||
on_update = NO_ACTION | ||
on_delete = NO_ACTION | ||
} | ||
index "category_id" { | ||
columns = [column.category_id] | ||
} | ||
index "supplier_id" { | ||
columns = [column.supplier_id] | ||
} | ||
} | ||
table "suppliers" { | ||
schema = schema.default | ||
column "supplier_id" { | ||
null = false | ||
type = int | ||
auto_increment = true | ||
} | ||
column "name" { | ||
null = false | ||
type = varchar(255) | ||
} | ||
column "contact_info" { | ||
null = true | ||
type = text | ||
} | ||
primary_key { | ||
columns = [column.supplier_id] | ||
} | ||
} | ||
schema "default" { | ||
charset = "utf8mb4" | ||
collate = "utf8mb4_0900_ai_ci" | ||
} |