Skip to content

Commit c70ee1f

Browse files
committed
Update
1 parent 03882b4 commit c70ee1f

File tree

7 files changed

+91
-5
lines changed

7 files changed

+91
-5
lines changed

DbProject/dbo/Tables/DimCustomer.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CREATE TABLE [dbo].[DimCustomer] (
2+
[CustomerKey] INT NOT NULL,
3+
[CustomerAltKey] VARCHAR (50) NULL,
4+
[Title] VARCHAR (5) NULL,
5+
[FirstName] VARCHAR (50) NOT NULL,
6+
[LastName] VARCHAR (50) NULL,
7+
[AddressLine1] VARCHAR (200) NULL,
8+
[City] VARCHAR (50) NULL,
9+
[StateProvince] VARCHAR (50) NULL,
10+
[CountryRegion] VARCHAR (50) NULL,
11+
[PostalCode] VARCHAR (20) NULL
12+
);
13+
14+
15+
GO
16+

DbProject/dbo/Tables/DimDate.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE [dbo].[DimDate] (
2+
[DateKey] INT NOT NULL,
3+
[DateAltKey] DATE NOT NULL,
4+
[DayOfWeek] INT NOT NULL,
5+
[WeekDayName] VARCHAR (10) NULL,
6+
[DayOfMonth] INT NOT NULL,
7+
[Month] INT NOT NULL,
8+
[MonthName] VARCHAR (12) NULL,
9+
[Year] INT NOT NULL
10+
);
11+
12+
13+
GO
14+

DbProject/dbo/Tables/DimProduct.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE [dbo].[DimProduct] (
2+
-- Update comment
3+
[ProductKey] INT NOT NULL,
4+
[ProductAltKey] VARCHAR (25) NULL,
5+
[ProductName] VARCHAR (50) NOT NULL,
6+
[Category] VARCHAR (50) NULL,
7+
[ListPrice] DECIMAL (18) NULL
8+
);
9+
10+
11+
GO
12+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE [dbo].[FactSalesOrder] (
2+
[SalesOrderKey] INT NOT NULL,
3+
[SalesOrderDateKey] INT NOT NULL,
4+
[ProductKey] INT NOT NULL,
5+
[CustomerKey] INT NOT NULL,
6+
[Quantity] INT NULL,
7+
[SalesTotal] DECIMAL (18) NULL
8+
);
9+
10+
GO
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
CREATE VIEW vSalesByRegion
4+
AS
5+
-- Deployment
6+
SELECT d.[Year] AS CalendarYear,
7+
d.[Month] AS MonthOfYear,
8+
d.MonthName AS MonthName,
9+
c.CountryRegion AS SalesRegion,
10+
SUM(so.SalesTotal) AS SalesRevenue
11+
FROM FactSalesOrder AS so
12+
JOIN DimDate AS d ON so.SalesOrderDateKey = d.DateKey
13+
JOIN DimCustomer AS c ON so.CustomerKey = c.CustomerKey
14+
GROUP BY d.[Year], d.[Month], d.MonthName, c.CountryRegion;
15+
16+
GO
17+

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@
55

66
## Overview
77

8-
> This project demonstrates how to deploy a [dacpac](https://learn.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications?view=sql-server-ver16) to an Azure SQL Database using a GitHub Action.
8+
> This project demonstrates how to automate database development with
9+
[dacpac](https://learn.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications?view=sql-server-ver16)
10+
to an Azure SQL Database using a GitHub Actions.
11+
12+
13+
## Flow
14+
15+
1. Database Project build
16+
2. DacPack file is created
17+
3. Contents of dacpac is consumed by Github Action
18+
4. Deploy against a database
19+
920

1021
## Prerequisites
1122
- Azure Subscription
1223

13-
1424
## Setup
15-
1. Create a new Azure SQL Database
16-
2. Create a new Azure Service Principal
17-
> See infra [README.md](../infra/README.md) for more details.
25+
1. Create a new Azure Service Principal
26+
2. Create a new Azure SQL Database, see infra [README.md](../infra/README.md) for more details.
1827

1928
## Configuration
2029
1. Add the following secrets to your GitHub repository:

tests/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# select all tables and views from sql server:
3+
4+
QUERY="
5+
SELECT * FROM INFORMATION_SCHEMA.TABLES
6+
"
7+
8+
docker exec -it --env-file .env db /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "$QUERY" -b

0 commit comments

Comments
 (0)