示例#1
0
        public void TestColumnAdd()
        {
            migrator.Table("users");

            IColumn column = migrator.AddColumn(new VarCharColumn("email", 100))
                             .Unique()
                             .NotNull();

            Assert.Equal(column.Name(), "email");
            Assert.Equal(column.Length(), 100);
            Assert.Equal(column.IsUnique(), true);
            Assert.Equal(column.IsNullable(), false);
            Assert.Equal(migrator.ColumnCount(), 1);

            column = migrator.GetColumnByName("email");
            Assert.Equal(column.IsNullable(), false);

            IColumn userTypeId = migrator.AddColumn(new IntColumn("user_type_id"));

            migrator.Create();
            Assert.Equal(
                "CREATE TABLE `users` (`email` VARCHAR(100) NOT NULL UNIQUE, `user_type_id` INT)",
                adaptor.GetLastSQL()
                );
        }