-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding schema designer files * More fixes * Fixing code * Fixing contracts * Cleaning up code * cleaning up code * Fixing query * Fixing database for connection * removing unused file * Fixing typo * Making some PR fixes * reordering enum * Fixing comments
- Loading branch information
1 parent
339caad
commit 6bd525b
Showing
7 changed files
with
518 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
30 changes: 30 additions & 0 deletions
30
src/Microsoft.SqlTools.ServiceLayer/SchemaDesigner/Contracts/Column.cs
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,30 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.SchemaDesigner | ||
{ | ||
/// <summary> | ||
/// Represents a column in an entity | ||
/// </summary> | ||
public class Column | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the column | ||
/// </summary> | ||
public string Name { get; set; } | ||
/// <summary> | ||
/// Gets or sets the data type of the column | ||
/// </summary> | ||
public string DataType { get; set; } | ||
/// <summary> | ||
/// Gets or sets if the column is a primary key | ||
/// </summary> | ||
public bool IsPrimaryKey { get; set; } | ||
/// <summary> | ||
/// Gets or sets if the column is an identity column | ||
/// </summary> | ||
public bool IsIdentity { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Microsoft.SqlTools.ServiceLayer/SchemaDesigner/Contracts/Entity.cs
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,16 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.SchemaDesigner | ||
{ | ||
public class Entity | ||
{ | ||
public string Name { get; set; } | ||
public string Schema { get; set; } | ||
public List<Column> Columns { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Microsoft.SqlTools.ServiceLayer/SchemaDesigner/Contracts/GetSchemaModelRequest.cs
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,30 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.SqlTools.Hosting.Protocol.Contracts; | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.SchemaDesigner | ||
{ | ||
public class GetSchemaModelRequestParams | ||
{ | ||
/// <summary> | ||
/// URI identifying the connection to perform the action on. Generally the connection is picked from an existing OE connection. | ||
/// </summary> | ||
public string ConnectionUri { get; set; } | ||
/// <summary> | ||
/// Gets or sets the name of the database. Database name is required to get the schema model for the database. | ||
/// </summary> | ||
public string DatabaseName { get; set; } | ||
} | ||
/// <summary> | ||
/// Request to get the schema model | ||
/// </summary> | ||
public class GetSchemaModelRequest | ||
{ | ||
public static readonly | ||
RequestType<GetSchemaModelRequestParams, SchemaModel> Type = | ||
RequestType<GetSchemaModelRequestParams, SchemaModel>.Create("schemaDesigner/getSchemaModel"); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/Microsoft.SqlTools.ServiceLayer/SchemaDesigner/Contracts/Relationship.cs
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,67 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.SchemaDesigner | ||
{ | ||
public class Relationship | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the foreign key | ||
/// </summary> | ||
public string ForeignKeyName { get; set; } | ||
/// <summary> | ||
/// Gets or sets the schema name | ||
/// </summary> | ||
public string SchemaName { get; set; } | ||
/// <summary> | ||
/// Gets or sets the parent entity (Table in MSSQL) name. | ||
/// </summary> | ||
public string Entity { get; set; } | ||
/// <summary> | ||
/// Gets or sets the parent column | ||
/// </summary> | ||
public string Column { get; set; } | ||
/// <summary> | ||
/// Gets or sets the referenced schema | ||
/// </summary> | ||
public string ReferencedSchema { get; set; } | ||
/// <summary> | ||
/// Gets or sets the referenced entity (Table in MSSQL) name. | ||
/// </summary> | ||
public string ReferencedEntity { get; set; } | ||
/// <summary> | ||
/// Gets or sets the referenced column | ||
/// </summary> | ||
public string ReferencedColumn { get; set; } | ||
/// <summary> | ||
/// Gets or sets the delete cascade action. Default is NO_ACTION | ||
/// </summary> | ||
public OnAction OnDeleteAction { get; set; } | ||
/// <summary> | ||
/// Gets or sets the update cascade action. Default is NO_ACTION | ||
/// </summary> | ||
public OnAction OnUpdateAction { get; set; } | ||
} | ||
|
||
public enum OnAction | ||
{ | ||
/// <summary> | ||
/// No action. Do not allow the delete or update of the row from the parent table if there are matching rows in the child table. | ||
/// </summary> | ||
NO_ACTION = 0, | ||
/// <summary> | ||
/// Cascade action. Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. | ||
/// </summary> | ||
CASCADE = 1, | ||
/// <summary> | ||
/// Set null action. Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. | ||
/// </summary> | ||
SET_NULL = 2, | ||
/// <summary> | ||
/// Set default action. Delete or update the row from the parent table and set the foreign key column or columns in the child table to their default values. | ||
/// </summary> | ||
SET_DEFAULT = 3 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Microsoft.SqlTools.ServiceLayer/SchemaDesigner/Contracts/SchemaModel.cs
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,21 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.SqlTools.ServiceLayer.SchemaDesigner | ||
{ | ||
public class SchemaModel | ||
{ | ||
/// <summary> | ||
/// Gets or sets the entities (Table in MSSQL) in the schema | ||
/// </summary> | ||
public List<Entity> Entities { get; set; } | ||
/// <summary> | ||
/// Gets or sets the relationships in the schema | ||
/// </summary> | ||
public List<Relationship> Relationships { get; set; } | ||
} | ||
} |
Oops, something went wrong.