Skip to content

Commit

Permalink
.github/workflows: add ci (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemtam authored Mar 7, 2024
1 parent 2463974 commit 3b1ac88
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/estore.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: Setup Atlas

name: EStore Inventory Pipeline
on:
push:
branches:
- master
pull_request:
branches:
- master

permissions:
contents: read
pull-requests: write
jobs:
setup:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Atlas
uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_PUBLIC_TENANT_TOKEN }}
- name: Lint Migrations
uses: ariga/atlas-action/migrate/lint@v1
with:
dir-name: 'estore-inventory'
dir: 'file://projects/estore/inventory/migrations'
env: 'local'
config: 'file://projects/estore/atlas.hcl'
- name: Push to Registry
if: github.ref == 'refs/heads/master'
uses: ariga/atlas-action/migrate/push@v1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Create "regions" table
CREATE TABLE `regions` (
`region_id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`region_id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
-- Create "warehouses" table
CREATE TABLE `warehouses` (
`warehouse_id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`address` text NOT NULL,
`region_id` int NULL,
PRIMARY KEY (`warehouse_id`),
INDEX `region_id` (`region_id`),
CONSTRAINT `warehouses_ibfk_1` FOREIGN KEY (`region_id`) REFERENCES `regions` (`region_id`) ON UPDATE NO ACTION ON DELETE NO ACTION
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
3 changes: 2 additions & 1 deletion projects/estore/inventory/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
h1:fo2R2MvvR2SDqpcg3lMGjPvOwppIJ3AIR7rtGh5zPpU=
h1:OD80uv7vCyCGr2x6dS4rLVaCkoj7JyydbcT6gxQAShI=
20240307092728.sql h1:BEXRAbglZQlUqXHRy4fvsEVsu7FlSfKcJ/JAkH2XgMY=
20240307104354_add_warehouses.sql h1:heT56DSu6Ka8TJo8K4F92rVxinZmt+7tbMX+y3vaJKo=
47 changes: 47 additions & 0 deletions projects/estore/inventory/schema.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ table "products" {
columns = [column.supplier_id]
}
}
table "regions" {
schema = schema.default
column "region_id" {
null = false
type = int
auto_increment = true
}
column "name" {
null = false
type = varchar(255)
}
primary_key {
columns = [column.region_id]
}
}
table "suppliers" {
schema = schema.default
column "supplier_id" {
Expand All @@ -86,6 +101,38 @@ table "suppliers" {
columns = [column.supplier_id]
}
}
table "warehouses" {
schema = schema.default
column "warehouse_id" {
null = false
type = int
auto_increment = true
}
column "name" {
null = false
type = varchar(255)
}
column "address" {
null = false
type = text
}
column "region_id" {
null = true
type = int
}
primary_key {
columns = [column.warehouse_id]
}
foreign_key "warehouses_ibfk_1" {
columns = [column.region_id]
ref_columns = [table.regions.column.region_id]
on_update = NO_ACTION
on_delete = NO_ACTION
}
index "region_id" {
columns = [column.region_id]
}
}
schema "default" {
charset = "utf8mb4"
collate = "utf8mb4_0900_ai_ci"
Expand Down

0 comments on commit 3b1ac88

Please sign in to comment.