question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stand-Alone SQL to build database

See original GitHub issue

@EdwinVW Would you mind posting a stand-along sql that builds out the database.

This is what I have so far, where some was derived from looking at code that relys on entity.


IF DB_ID('WorkshopManagement') IS NULL CREATE DATABASE WorkshopManagement;

IF DB_ID('CustomerManagement') IS NULL CREATE DATABASE CustomerManagement;
IF DB_ID('VehicleManagement') IS NULL CREATE DATABASE VehicleManagement;
IF DB_ID('WorkshopManagementEventStore') IS NULL CREATE DATABASE WorkshopManagementEventStore;
IF DB_ID('Invoicing') IS NULL CREATE DATABASE Invoicing;
IF DB_ID('Notification') IS NULL CREATE DATABASE Notification;

DROP TABLE IF EXISTS CustomerManagement.dbo.Customer;
if OBJECT_ID('CustomerManagement.dbo.Customer') IS NULL 
    CREATE TABLE CustomerManagement.dbo.Customer (
        [CustomerId] varchar(50) NOT NULL,
        [Name] varchar(50) NOT NULL,
        [Address] varchar(50) NOT NULL,
        [PostalCode] varchar(50) NOT NULL,
        [City] varchar(50) NOT NULL,
        [TelephoneNumber] varchar(50) NOT NULL,
        [EmailAddress] varchar(50) NOT NULL,
    PRIMARY KEY([CustomerId]));

DROP TABLE IF EXISTS VehicleManagement.dbo.Vehicle;
if OBJECT_ID('VehicleManagement.dbo.Vehicle') IS NULL 
    CREATE TABLE VehicleManagement.dbo.Vehicle (
        [LicenseNumber] varchar(50) NOT NULL,
        [Brand] varchar(50) NOT NULL,
        [Type] varchar(50) NOT NULL,
        [OwnerId] varchar(50) NOT NULL,
    PRIMARY KEY([LicenseNumber]));

DROP TABLE IF EXISTS WorkshopManagementEventStore.dbo.WorkshopPlanningEvent;
DROP TABLE IF EXISTS WorkshopManagementEventStore.dbo.WorkshopPlanning;

if OBJECT_ID('WorkshopManagementEventStore.dbo.WorkshopPlanning') IS NULL 
    CREATE TABLE WorkshopManagementEventStore.dbo.WorkshopPlanning (
        [Id] varchar(50) NOT NULL,
        [CurrentVersion] int NOT NULL,
    PRIMARY KEY([Id]));
    
if OBJECT_ID('WorkshopManagementEventStore.dbo.WorkshopPlanningEvent') IS NULL
    CREATE TABLE WorkshopManagementEventStore.dbo.WorkshopPlanningEvent (
        [Id] varchar(50) NOT NULL REFERENCES WorkshopManagementEventStore.dbo.WorkshopPlanning([Id]),
        [Version] int NOT NULL,
        [Timestamp] datetime2(7) NOT NULL,
        [MessageType] varchar(75) NOT NULL,
        [EventData] text,
    PRIMARY KEY([Id], [Version]));

DROP TABLE IF EXISTS Invoicing.dbo.Customer;
IF OBJECT_ID('Invoicing.dbo.Customer') IS NULL 
    CREATE TABLE Invoicing.dbo.Customer (
        CustomerId varchar(50) NOT NULL,
            Name varchar(50) NOT NULL,
            Address varchar(50),
            PostalCode varchar(50),
            City varchar(50),
        PRIMARY KEY(CustomerId));

DROP TABLE IF EXISTS Invoicing.dbo.MaintenanceJob;
IF OBJECT_ID('Invoicing.dbo.MaintenanceJob') IS NULL 
    CREATE TABLE Invoicing.dbo.MaintenanceJob (
        JobId varchar(50) NOT NULL,
        LicenseNumber varchar(50) NOT NULL,
        CustomerId varchar(50) NOT NULL,
        Description varchar(250) NOT NULL,
        StartTime datetime2 NULL,
        EndTime datetime2 NULL,
        Finished bit NOT NULL,
        InvoiceSent bit NOT NULL,
    PRIMARY KEY(JobId));

DROP TABLE IF EXISTS Invoicing.dbo.Invoice;
IF OBJECT_ID('Invoicing.dbo.Invoice') IS NULL 
    CREATE TABLE Invoicing.dbo.Invoice (
        InvoiceId varchar(50) NOT NULL,
        InvoiceDate datetime2 NOT NULL,
        CustomerId varchar(50) NOT NULL,
        Amount decimal(5,2) NOT NULL,
        Specification text,
        JobIds varchar(250),
    PRIMARY KEY(InvoiceId));

DROP TABLE IF EXISTS Notification.dbo.Customer;
IF OBJECT_ID('Notification.dbo.Customer') IS NULL 
    CREATE TABLE Notification.dbo.Customer (
        CustomerId varchar(50) NOT NULL,
        Name varchar(50) NOT NULL,
        TelephoneNumber varchar(50),
        EmailAddress varchar(50),
    PRIMARY KEY(CustomerId));

DROP TABLE IF EXISTS Notification.dbo.MaintenanceJob;
IF OBJECT_ID('Notification.dbo.MaintenanceJob') IS NULL 
    CREATE TABLE Notification.dbo.MaintenanceJob (
        JobId varchar(50) NOT NULL,
        LicenseNumber varchar(50) NOT NULL,
        CustomerId varchar(50) NOT NULL,
        StartTime datetime2 NOT NULL,
        Description varchar(250) NOT NULL,
    PRIMARY KEY(JobId));


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghstahlcommented, Oct 28, 2019

So, I was working on converting this to grpc. Then it turned into thinking about writing a few of the services in golang. Which then lead me to the dotnetcore entity stuff as the system of record for the tables.

Then it was like: “Hey, this whole thing could be in golang, nats, etc”, which makes the database creation and migration its own thing.

On Sat, Oct 26, 2019 at 6:38 AM Edwin van Wijk notifications@github.com wrote:

@ghstahl https://github.com/ghstahl you can generate the DDL from the databases once they’re created from SQL Server Management Studio.

Out of curiosity: why would you need such a script? The databases are created automatically when the services are started.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EdwinVW/pitstop/issues/46?email_source=notifications&email_token=AABREKNVQXOJIRW5ECIA52DQQRB3VA5CNFSM4JEWHCSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECKICRY#issuecomment-546603335, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABREKOHVG2HQQS4AVKW66LQQRB3VANCNFSM4JEWHCSA .

1reaction
CodeWithKashifcommented, Oct 26, 2019

@edwinvw in my case i had setup that complete project with dapper as my organisation is not big fan of entity framework(because of performance and other reason) instead we would like to use any micro orm, hence dapper is first choice

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating SQL Server databases in a stand-alone ... - IBM
If you want to use the BPMConfig command to create the stand-alone profile separately from the database tables, you can first run the...
Read more >
Create a New Database Project - SQL Server Data Tools (SSDT)
You can create a new database project and import database schema from an existing database, a .sql script file or a Data-tier application ......
Read more >
Configure a standalone SQL Server node as database ... - AWS
On the primary FCI, open SQL Server Management Studio (SSMS) and connect to the FCI cluster SQL Server. · Create a new database...
Read more >
Installing with database on a stand-alone SQL server
Creating a database on stand-alone SQL Server · Select the SQL Server instance from the drop-down menu or type in the name of...
Read more >
Standalone SQL Server Instance Installation using setup
SQL Server Management Studio (SSMS) | Full Course · How to Install & Configure SQL Server 2016 Failover Cluster Step By Step ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found