Skip to content

Commit b87ec7a

Browse files
Merge pull request #142 from dotnetprojects/add-primary-key
Oracle Identity: Replace trigger by Generated by
2 parents a8200ef + 7fea164 commit b87ec7a

File tree

56 files changed

+1643
-624
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1643
-624
lines changed

.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ spelling_exclusion_path = SpellingExclusions.dic
88

99
# Code files
1010
[*.{cs,csx,vb,vbx}]
11+
end_of_line = lf
1112
indent_size = 4
1213
insert_final_newline = true
1314
charset = utf-8
1415

1516
# XML project files
1617
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
17-
indent_size = 2
18+
indent_size = 4
19+
end_of_line = lf
1820

1921
# XML config files
2022
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
@@ -155,6 +157,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
155157
dotnet_style_prefer_compound_assignment = true:suggestion
156158
dotnet_style_prefer_simplified_interpolation = true:suggestion
157159
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
160+
tab_width = 4
158161

159162
##########################################
160163
# C# Specific settings
@@ -223,7 +226,7 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
223226
csharp_style_prefer_init_only_properties = true:suggestion
224227

225228
# Braces
226-
csharp_prefer_braces = always:warning
229+
csharp_prefer_braces = true:silent
227230
csharp_preserve_single_line_blocks = true
228231
csharp_preserve_single_line_statements = true
229232
dotnet_diagnostic.IDE0011.severity = warning
@@ -271,6 +274,12 @@ dotnet_diagnostic.IDE2005.severity = warning
271274
dotnet_diagnostic.IDE2006.severity = warning
272275
csharp_style_expression_bodied_lambdas = true:silent
273276
csharp_style_expression_bodied_local_functions = false:silent
277+
csharp_using_directive_placement = outside_namespace:silent
278+
csharp_prefer_simple_using_statement = true:suggestion
279+
csharp_style_prefer_method_group_conversion = true:silent
280+
csharp_style_prefer_top_level_statements = true:silent
281+
csharp_style_prefer_primary_constructors = true:suggestion
282+
csharp_prefer_system_threading_lock = true:suggestion
274283

275284
##########################################
276285
# Exceptions by path

.github/workflows/dotnetpull.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [master]
88
jobs:
99
build:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-22.04
1111
services:
1212
sqlserver:
1313
image: mcr.microsoft.com/mssql/server:2019-latest
@@ -68,11 +68,18 @@ jobs:
6868
with:
6969
dotnet-version: |
7070
9.0.x
71-
- name: Install SQLCMD tools
71+
- name: Install Microsoft GPG apt-key
72+
run: |
73+
wget https://packages.microsoft.com/keys/microsoft.asc -O microsoft.asc
74+
gpg --dearmor microsoft.asc
75+
chmod 644 microsoft.asc.gpg
76+
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
77+
- name: Add Microsoft SQL Server repo
7278
run: |
73-
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
74-
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
79+
echo "deb [arch=amd64] https://packages.microsoft.com/config/ubuntu/22.04/prod jammy main"
7580
sudo apt-get update
81+
- name: Install SQLCMD tools
82+
run: |
7683
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
7784
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
7885
source ~/.bashrc

.github/workflows/sql/oracle.sql

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@ alter session set container = freepdb1;
44

55
create user k identified by k;
66

7-
grant
8-
create user
9-
to k;
10-
11-
grant
12-
drop user
13-
to k;
14-
15-
grant
16-
create session
17-
to k with admin option;
18-
7+
grant select_catalog_role to k;
8+
grant create tablespace to k;
9+
grant drop tablespace to k;
10+
grant create user to k;
11+
grant drop user to k;
12+
grant create session to k with admin option;
1913
grant resource to k with admin option;
20-
2114
grant connect to k with admin option;
22-
23-
grant
24-
unlimited tablespace
25-
to k with admin option;
26-
27-
grant select on v_$session to k with grant option
28-
29-
grant
30-
alter system
31-
to k
15+
grant unlimited tablespace to k with admin option;
16+
grant select on v_$session to k with grant option;
17+
grant alter system to k;
3218

3319
exit;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using LinqToDB.Mapping;
2+
using Migrator.Tests.Database.Data.Common.Interfaces;
3+
4+
namespace Migrator.Tests.Database.Data.Common;
5+
6+
public abstract class EntityConfiguration<T>(FluentMappingBuilder fluentMappingBuilder) : IEntityConfiguration where T : class
7+
{
8+
protected EntityMappingBuilder<T> _EntityMappingBuilder = fluentMappingBuilder.Entity<T>();
9+
protected FluentMappingBuilder _FluentMappingBuilder = fluentMappingBuilder;
10+
11+
/// <summary>
12+
/// Configures the entity in the fluent migrator of Linq2db
13+
/// </summary>
14+
public abstract void ConfigureEntity();
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Migrator.Tests.Database.Data.Common.Interfaces;
2+
3+
public interface IEntityConfiguration
4+
{
5+
/// <summary>
6+
/// Configure the entity mapping.
7+
/// </summary>
8+
void ConfigureEntity();
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using LinqToDB.Mapping;
2+
3+
namespace Migrator.Tests.Database.Data.Common.Interfaces;
4+
5+
public interface IMappingSchemaFactory
6+
{
7+
MappingSchema CreateOracleMappingSchema();
8+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Collections.Generic;
2+
using LinqToDB.Mapping;
3+
using Migrator.Tests.Database.Data.Common.Interfaces;
4+
using Migrator.Tests.Database.Data.Mappings.Oracle;
5+
6+
namespace DotNetProjects.Migrator.Framework.Data.Common;
7+
8+
public class MappingSchemaFactory() : IMappingSchemaFactory
9+
{
10+
public MappingSchema CreateOracleMappingSchema()
11+
{
12+
var fluentMappingBuilder = new FluentMappingBuilder();
13+
14+
var configs = new List<IEntityConfiguration>
15+
{
16+
new OracleAllConsColumnsConfiguration(fluentMappingBuilder),
17+
new OracleAllConstraintsConfiguration(fluentMappingBuilder),
18+
new OracleAllTabColumnsConfiguration(fluentMappingBuilder),
19+
new OracleAllTabColumnsConfiguration(fluentMappingBuilder),
20+
new OracleAllUsersConfiguration(fluentMappingBuilder),
21+
new OracleDBADataFilesConfiguration(fluentMappingBuilder),
22+
new OracleVSessionConfiguration(fluentMappingBuilder),
23+
};
24+
25+
return Configure(fluentMappingBuilder, configs);
26+
}
27+
28+
private static MappingSchema Configure(FluentMappingBuilder fluentMappingBuilder, IEnumerable<IEntityConfiguration> entityConfigurations)
29+
{
30+
foreach (var config in entityConfigurations)
31+
{
32+
config.ConfigureEntity();
33+
}
34+
35+
fluentMappingBuilder.Build();
36+
37+
return fluentMappingBuilder.MappingSchema;
38+
}
39+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
2+
using LinqToDB.Mapping;
3+
using Migrator.Tests.Database.Data.Common;
4+
5+
namespace Migrator.Tests.Database.Data.Mappings.Oracle;
6+
7+
public class OracleAllConsColumnsConfiguration(FluentMappingBuilder fluentMappingBuilder)
8+
: EntityConfiguration<AllConsColumns>(fluentMappingBuilder)
9+
{
10+
public override void ConfigureEntity()
11+
{
12+
_EntityMappingBuilder!.HasTableName("ALL_CONS_COLUMNS");
13+
14+
_EntityMappingBuilder.Property(x => x.ColumnName)
15+
.HasColumnName("COLUMN_NAME");
16+
17+
_EntityMappingBuilder.Property(x => x.ConstraintName)
18+
.HasColumnName("CONSTRAINT_NAME");
19+
20+
_EntityMappingBuilder.Property(x => x.Owner)
21+
.HasColumnName("OWNER");
22+
23+
_EntityMappingBuilder.Property(x => x.Position)
24+
.HasColumnName("POSITION");
25+
26+
_EntityMappingBuilder.Property(x => x.TableName)
27+
.HasColumnName("TABLE_NAME");
28+
}
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
2+
using LinqToDB.Mapping;
3+
using Migrator.Tests.Database.Data.Common;
4+
5+
namespace Migrator.Tests.Database.Data.Mappings.Oracle;
6+
7+
public class OracleAllConstraintsConfiguration(FluentMappingBuilder fluentMappingBuilder)
8+
: EntityConfiguration<AllConstraints>(fluentMappingBuilder)
9+
{
10+
public override void ConfigureEntity()
11+
{
12+
_EntityMappingBuilder!.HasTableName("ALL_CONSTRAINTS");
13+
14+
_EntityMappingBuilder.Property(x => x.ConstraintName)
15+
.HasColumnName("CONSTRAINT_NAME");
16+
17+
_EntityMappingBuilder.Property(x => x.RConstraintName)
18+
.HasColumnName("R_CONSTRAINT_NAME");
19+
20+
_EntityMappingBuilder.Property(x => x.ROwner)
21+
.HasColumnName("R_OWNER");
22+
23+
_EntityMappingBuilder.Property(x => x.ConstraintType)
24+
.HasColumnName("CONSTRAINT_TYPE");
25+
26+
_EntityMappingBuilder.Property(x => x.Owner)
27+
.HasColumnName("OWNER");
28+
29+
_EntityMappingBuilder.Property(x => x.Status)
30+
.HasColumnName("STATUS");
31+
32+
_EntityMappingBuilder.Property(x => x.TableName)
33+
.HasColumnName("TABLE_NAME");
34+
}
35+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
2+
using LinqToDB.Mapping;
3+
using Migrator.Tests.Database.Data.Common;
4+
5+
namespace Migrator.Tests.Database.Data.Mappings.Oracle;
6+
7+
public class OracleAllTabColumnsConfiguration(FluentMappingBuilder fluentMappingBuilder)
8+
: EntityConfiguration<AllTabColumns>(fluentMappingBuilder)
9+
{
10+
public override void ConfigureEntity()
11+
{
12+
_EntityMappingBuilder!.HasTableName("ALL_TAB_COLUMNS");
13+
14+
_EntityMappingBuilder.Property(x => x.ColumnName)
15+
.HasColumnName("COLUMN_NAME");
16+
17+
_EntityMappingBuilder.Property(x => x.DataDefault)
18+
.HasColumnName("DATA_DEFAULT");
19+
20+
_EntityMappingBuilder.Property(x => x.DataLength)
21+
.HasColumnName("DATA_LENGTH");
22+
23+
_EntityMappingBuilder.Property(x => x.DataType)
24+
.HasColumnName("DATA_TYPE");
25+
26+
_EntityMappingBuilder.Property(x => x.IdentityColumn)
27+
.HasColumnName("IDENTITY_COLUMN");
28+
29+
_EntityMappingBuilder.Property(x => x.Nullable)
30+
.HasColumnName("NULLABLE");
31+
32+
_EntityMappingBuilder.Property(x => x.Owner)
33+
.HasColumnName("OWNER");
34+
35+
_EntityMappingBuilder.Property(x => x.TableName)
36+
.HasColumnName("TABLE_NAME");
37+
}
38+
}

0 commit comments

Comments
 (0)