sougatamondal / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

Indexed not being created as part of AddTable migration #39

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
See the migration below.  The index on the UserId column for the Customer
table is not being created.

[Migration(2)]
public class CreateCustomerTable : Migration
{
    public override void Up()
    {
        Database.AddTable("[Customer]", 
            new Column("CustomerId", DbType.Int32,
ColumnProperty.PrimaryKeyWithIdentity),
            new Column("UserId", DbType.Int32, ColumnProperty.NotNull |
ColumnProperty.Indexed),
            new Column("[Name]", DbType.String, 100, ColumnProperty.NotNull),
            new Column("Address", DbType.String, 255, ColumnProperty.NotNull),
            new Column("Telephone", DbType.String, 30,
ColumnProperty.NotNull));

        Database.AddForeignKey("FK_CUSTOMER_USER", "[Customer]", "UserId",
"[User]", "UserId");
    }

    public override void Down()
    {
        Database.RemoveForeignKey("[Customer]", "FK_CUSTOMER_USER");
        Database.RemoveTable("[Customer]");
    }
}

Original issue reported on code.google.com by carel.l...@gmail.com on 18 Jun 2008 at 7:55

GoogleCodeExporter commented 8 years ago
Hi, this issue should be improved. Current indexed property is not so 
useful...what 
if i want to declare two different index of one column each? how i 
differentiate 
this from one index with tho columns?
How do i set the index should be unique or not, clustered or not?

I think we should open something like Database.AddIndex(table, columnnames[], 
order
[], unique, clustered)

Opinions?

Original comment by gustavo.ringel@gmail.com on 18 Jun 2008 at 8:04

GoogleCodeExporter commented 8 years ago
The order there is because i recall there is the option to make Ascending an 
descending order in the indexes, if not it is irrelevant.

Original comment by gustavo.ringel@gmail.com on 18 Jun 2008 at 8:06

GoogleCodeExporter commented 8 years ago
The order there is because i recall there is the option to make Ascending an 
descending order in the indexes, if not it is irrelevant.

Original comment by gustavo.ringel@gmail.com on 18 Jun 2008 at 8:06

GoogleCodeExporter commented 8 years ago
I agree

I think we should remove the index related flags from the ColumnProperty enum 
and
provide a dedicated set of methods to add/remove indexes on columns in tables.

Original comment by carel.l...@gmail.com on 19 Jun 2008 at 10:41

GoogleCodeExporter commented 8 years ago
+1 to that.

For creating something that could possibly span columns, it really needs to be 
its 
own method instead of adding it to the column definition. Much like adding keys 
to 
columns by use of Database.AddForeignKey.

If someone would like to supply a patch, or when I get a chance I will add this 
behavior.

Original comment by dko...@gmail.com on 22 Jun 2008 at 12:50

GoogleCodeExporter commented 8 years ago

Original comment by dko...@gmail.com on 22 Jun 2008 at 12:50

GoogleCodeExporter commented 8 years ago
Hi, i already developed de addindex function and even i'm working with it in 
SQL 
Server. 
I found the problem there is no generic way to write an IndexExists function...
So, i have some options now...
1) Live the AddIndex (ANSI-SQL) there in the top so everyone can use it, and 
make 
tests for those DB's where i found and can test it worked.
2) Put the AddIndex only in the Providers where i can test
3) leaving it as it is now without addindex

There are for anyway missing tests for this as you should know, there was no 
passing 
test for SQL nor for the other RDBMS that were really creating an index when 
ColumnProperty.Indexed was set...

Well tell me which way to take...considering it is ANSI-SQL i'm in favor of a 
test 
that at least calls the functions and don't fails...

Original comment by gustavo.ringel@gmail.com on 27 Jun 2008 at 12:23

GoogleCodeExporter commented 8 years ago

Original comment by geoffl...@gmail.com on 4 Aug 2008 at 10:58