/// <summary>
        /// Creates the table used for tracking uniques
        /// </summary>

        public static void InitStorage(DbConnection db, string tableName = Table, string schema = null)
        {
            IdempotencyTools.CreateStorage(db, schema);
            var name = db.Provider().EscapeTableName(new TableName(tableName, schema));

            db.CreateStorage(cf =>
            {
                cf.When <SqlServer2012Provider>(
                    $@"
create table {name}(
Id int not null identity(1,1) primary key,
EntityId uniqueidentifier not null,
[Scope] char(32) not null,
[Aspect] char(32) not null,
[Value] char(32) not null,
[Bucket] char(32) not null,
unique([Bucket],[Scope],[Aspect],[Value])
);
create index idx_US_Values on {name} (EntityId)
").When <SqliteProvider>(
                    $@"
create table if not exists {name}(
EntityId uniqueidentifier not null,
[Scope] char(32) not null,
[Aspect] char(32) not null,
[Value] char(32) not null,
[Bucket] char(32) not null,
unique([Bucket],[Scope],[Aspect],[Value])
);
create index if not exists idx_US_Values on {name} (EntityId)
");
            }, c =>
            {
                c.ConfigureTableForPoco <UniqueStoreRow>(t =>
                {
                    t.TableName = name;
                });
            });
        }
Exemplo n.º 2
0
 protected override void Init()
 {
     IdempotencyTools.CreateStorage(_db);
 }