Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ spelling_exclusion_path = SpellingExclusions.dic

# Code files
[*.{cs,csx,vb,vbx}]
end_of_line = lf
indent_size = 4
insert_final_newline = true
charset = utf-8

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
indent_size = 4
end_of_line = lf

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
Expand Down Expand Up @@ -155,6 +157,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
tab_width = 4

##########################################
# C# Specific settings
Expand Down Expand Up @@ -223,7 +226,7 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_prefer_init_only_properties = true:suggestion

# Braces
csharp_prefer_braces = always:warning
csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
dotnet_diagnostic.IDE0011.severity = warning
Expand Down Expand Up @@ -271,6 +274,12 @@ dotnet_diagnostic.IDE2005.severity = warning
dotnet_diagnostic.IDE2006.severity = warning
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion

##########################################
# Exceptions by path
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/dotnetpull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
Expand Down Expand Up @@ -68,11 +68,18 @@ jobs:
with:
dotnet-version: |
9.0.x
- name: Install SQLCMD tools
- name: Install Microsoft GPG apt-key
run: |
wget https://packages.microsoft.com/keys/microsoft.asc -O microsoft.asc
gpg --dearmor microsoft.asc
chmod 644 microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
- name: Add Microsoft SQL Server repo
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
echo "deb [arch=amd64] https://packages.microsoft.com/config/ubuntu/22.04/prod jammy main"
sudo apt-get update
- name: Install SQLCMD tools
run: |
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Expand Down
32 changes: 9 additions & 23 deletions .github/workflows/sql/oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,16 @@ alter session set container = freepdb1;

create user k identified by k;

grant
create user
to k;

grant
drop user
to k;

grant
create session
to k with admin option;

grant select_catalog_role to k;
grant create tablespace to k;
grant drop tablespace to k;
grant create user to k;
grant drop user to k;
grant create session to k with admin option;
grant resource to k with admin option;

grant connect to k with admin option;

grant
unlimited tablespace
to k with admin option;

grant select on v_$session to k with grant option

grant
alter system
to k
grant unlimited tablespace to k with admin option;
grant select on v_$session to k with grant option;
grant alter system to k;

exit;
15 changes: 15 additions & 0 deletions src/Migrator.Tests/Database/Data/Common/EntityConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common.Interfaces;

namespace Migrator.Tests.Database.Data.Common;

public abstract class EntityConfiguration<T>(FluentMappingBuilder fluentMappingBuilder) : IEntityConfiguration where T : class
{
protected EntityMappingBuilder<T> _EntityMappingBuilder = fluentMappingBuilder.Entity<T>();
protected FluentMappingBuilder _FluentMappingBuilder = fluentMappingBuilder;

/// <summary>
/// Configures the entity in the fluent migrator of Linq2db
/// </summary>
public abstract void ConfigureEntity();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Migrator.Tests.Database.Data.Common.Interfaces;

public interface IEntityConfiguration
{
/// <summary>
/// Configure the entity mapping.
/// </summary>
void ConfigureEntity();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using LinqToDB.Mapping;

namespace Migrator.Tests.Database.Data.Common.Interfaces;

public interface IMappingSchemaFactory
{
MappingSchema CreateOracleMappingSchema();
}
39 changes: 39 additions & 0 deletions src/Migrator.Tests/Database/Data/Common/MappingSchemaFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common.Interfaces;
using Migrator.Tests.Database.Data.Mappings.Oracle;

namespace DotNetProjects.Migrator.Framework.Data.Common;

public class MappingSchemaFactory() : IMappingSchemaFactory
{
public MappingSchema CreateOracleMappingSchema()
{
var fluentMappingBuilder = new FluentMappingBuilder();

var configs = new List<IEntityConfiguration>
{
new OracleAllConsColumnsConfiguration(fluentMappingBuilder),
new OracleAllConstraintsConfiguration(fluentMappingBuilder),
new OracleAllTabColumnsConfiguration(fluentMappingBuilder),
new OracleAllTabColumnsConfiguration(fluentMappingBuilder),
new OracleAllUsersConfiguration(fluentMappingBuilder),
new OracleDBADataFilesConfiguration(fluentMappingBuilder),
new OracleVSessionConfiguration(fluentMappingBuilder),
};

return Configure(fluentMappingBuilder, configs);
}

private static MappingSchema Configure(FluentMappingBuilder fluentMappingBuilder, IEnumerable<IEntityConfiguration> entityConfigurations)
{
foreach (var config in entityConfigurations)
{
config.ConfigureEntity();
}

fluentMappingBuilder.Build();

return fluentMappingBuilder.MappingSchema;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleAllConsColumnsConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<AllConsColumns>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("ALL_CONS_COLUMNS");

_EntityMappingBuilder.Property(x => x.ColumnName)
.HasColumnName("COLUMN_NAME");

_EntityMappingBuilder.Property(x => x.ConstraintName)
.HasColumnName("CONSTRAINT_NAME");

_EntityMappingBuilder.Property(x => x.Owner)
.HasColumnName("OWNER");

_EntityMappingBuilder.Property(x => x.Position)
.HasColumnName("POSITION");

_EntityMappingBuilder.Property(x => x.TableName)
.HasColumnName("TABLE_NAME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleAllConstraintsConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<AllConstraints>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("ALL_CONSTRAINTS");

_EntityMappingBuilder.Property(x => x.ConstraintName)
.HasColumnName("CONSTRAINT_NAME");

_EntityMappingBuilder.Property(x => x.RConstraintName)
.HasColumnName("R_CONSTRAINT_NAME");

_EntityMappingBuilder.Property(x => x.ROwner)
.HasColumnName("R_OWNER");

_EntityMappingBuilder.Property(x => x.ConstraintType)
.HasColumnName("CONSTRAINT_TYPE");

_EntityMappingBuilder.Property(x => x.Owner)
.HasColumnName("OWNER");

_EntityMappingBuilder.Property(x => x.Status)
.HasColumnName("STATUS");

_EntityMappingBuilder.Property(x => x.TableName)
.HasColumnName("TABLE_NAME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleAllTabColumnsConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<AllTabColumns>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("ALL_TAB_COLUMNS");

_EntityMappingBuilder.Property(x => x.ColumnName)
.HasColumnName("COLUMN_NAME");

_EntityMappingBuilder.Property(x => x.DataDefault)
.HasColumnName("DATA_DEFAULT");

_EntityMappingBuilder.Property(x => x.DataLength)
.HasColumnName("DATA_LENGTH");

_EntityMappingBuilder.Property(x => x.DataType)
.HasColumnName("DATA_TYPE");

_EntityMappingBuilder.Property(x => x.IdentityColumn)
.HasColumnName("IDENTITY_COLUMN");

_EntityMappingBuilder.Property(x => x.Nullable)
.HasColumnName("NULLABLE");

_EntityMappingBuilder.Property(x => x.Owner)
.HasColumnName("OWNER");

_EntityMappingBuilder.Property(x => x.TableName)
.HasColumnName("TABLE_NAME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleAllUsersConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<AllUsers>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("ALL_USERS");

_EntityMappingBuilder.Property(x => x.UserName)
.HasColumnName("USERNAME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleDBADataFilesConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<DBADataFiles>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("DBA_DATA_FILES");

_EntityMappingBuilder.Property(x => x.FileName)
.HasColumnName("FILE_NAME");

_EntityMappingBuilder.Property(x => x.TablespaceName)
.HasColumnName("TABLESPACE_NAME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DotNetProjects.Migrator.Framework.Data.Models.Oracle;
using LinqToDB.Mapping;
using Migrator.Tests.Database.Data.Common;

namespace Migrator.Tests.Database.Data.Mappings.Oracle;

public class OracleVSessionConfiguration(FluentMappingBuilder fluentMappingBuilder)
: EntityConfiguration<VSession>(fluentMappingBuilder)
{
public override void ConfigureEntity()
{
_EntityMappingBuilder!.HasTableName("V$SESSION");

_EntityMappingBuilder.Property(x => x.SerialHashTag)
.HasColumnName("SERIAL#");

_EntityMappingBuilder.Property(x => x.SID)
.HasColumnName("SID");

_EntityMappingBuilder.Property(x => x.UserName)
.HasColumnName("USERNAME");
}
}
Loading
Loading