microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
307 stars 18 forks source link

Composite Tables #362

Open airwedge1 opened 10 months ago

airwedge1 commented 10 months ago

Describe the solution you'd like I'd like to be able to extend the definition of tables into multiple files or projects. For example In SharedProject have a table FooBar and then in MyProject have a file FooBarCustom where the definition is alter table FooBar add MyCustomColumn.

Describe alternatives you've considered As an alternative I do not use database references instead I include my project as git sub module and just include / exclude individual files to accomplish similar behavior. However, if a column is added in the SharedProject to a table it needs to be manually added to my custom table definition.

dzsquared commented 10 months ago

Making sure I understand this correctly - you want a single table where in 1 project you define a few columns on it, and in another project you define other columns on it.

shared project

create table dbo.FoorBar (
    Id INT PRIMARY KEY,
    SomeColumn NVARCHAR(100)
)

MyProject

create table dbo.FoorBar (
    Id INT PRIMARY KEY,
    MyCustomColumn NVARCHAR(25)
)

MyProject has a database reference to the shared project

The end result is the table definition from SharedProject is layered under MyProject and any deployment plans are created from a combination of the 2 tables. if both have a primary key defined that doesn't match, does that cause a build error?

airwedge1 commented 10 months ago

That is all correct and yes it would cause a build error with more than one primary key, duplicate column names, etc. I would think that it would be easier to do it like the below but either way would work.

shared project

create table dbo.FoorBar ( Id INT PRIMARY KEY, SomeColumn NVARCHAR(100) )

MyProject

Alter table dbo.FoorBar Add MyCustomColumn NVARCHAR(25)


From: Drew Skwiers-Koballa @.> Sent: Friday, November 10, 2023 10:47:20 PM To: microsoft/DacFx @.> Cc: Nick Walker @.>; Author @.> Subject: Re: [microsoft/DacFx] Composite Tables (Issue #362)

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Making sure I understand this correctly - you want a single table where in 1 project you define a few columns on it, and in another project you define other columns on it.

shared project

create table dbo.FoorBar ( Id INT PRIMARY KEY, SomeColumn NVARCHAR(100) )

MyProject

create table dbo.FoorBar ( Id INT PRIMARY KEY, MyCustomColumn NVARCHAR(25) )

MyProject has a database reference to the shared project

The end result is the table definition from SharedProject is layered under MyProject and any deployment plans are created from a combination of the 2 tables. if both have a primary key defined that doesn't match, does that cause a build error?

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/DacFx/issues/362#issuecomment-1806663295, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKJPXBUO65ZOLXSHQNIUGELYD3YMRAVCNFSM6AAAAAA7GNJRSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWGY3DGMRZGU. You are receiving this because you authored the thread.Message ID: @.***>