Columns are always NotNullable (as a default)
See original GitHub issueI have the following migration (one of many, and it is a typical ASP.NET Identity table):
Create.Table("aspnet_users")
.WithColumn("id").AsGuid().PrimaryKey().NotNullable()
.WithColumn("username").AsString()
.WithColumn("normalized_username").AsString()
.WithColumn("email").AsString()
.WithColumn("normalized_email").AsString()
.WithColumn("email_confirmed").AsBoolean().NotNullable()
.WithColumn("password_hash").AsString()
.WithColumn("security_stamp").AsString()
.WithColumn("concurrency_stamp").AsString()
.WithColumn("phone_number").AsString()
.WithColumn("phone_number_confirmed").AsBoolean().NotNullable()
.WithColumn("two_factor_enabled").AsBoolean().NotNullable()
.WithColumn("lockout_end").AsDateTime()
.WithColumn("lockout_enabled").AsBoolean().NotNullable()
.WithColumn("access_failed_count").AsInt32().NotNullable()
.WithColumn("display_name").AsString();
My assumption was that unless NotNullable
is specified the column would default to Nullable
. However after the migration has ran, all the columns are NotNullable
.
I’m using Postgresql. Am I doing something wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
SQL Server: why is it possible to set default NULL value on ...
Yes, you can say bit NOT NULL DEFAULT NULL (example). As explained, the purpose is to ensure that if someone tries to avoid...
Read more >Why you Should Always Specify Whether a Column ...
Look there! NOT NULL constraints on all the columns, even though your connection settings specified that allowing them was the default.
Read more >Rails/NotNullColumn: Why are defaults required? #237
I'd like to generate some discussion on why this cop is requiring defaults for not-nullable columns. First: $ bundle exec rubocop -V 0.76.0 ......
Read more >Is there a compelling reason why columns in SQL are ...
No. There is no compelling reason why SQL defaults to nullable. In fact, many prominent researchers in relational database theory have disagreed ...
Read more >How Default Value and Nullable Column Works?
When a user adds a column with default to a table in SQL Server, which already exists, it always checks the nullable property...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It also seems as though SQL Server lets you change the default behavior of implicit syntax, so FluentMigrator should explicitly specify null or not null. See:
SET ANSI_NULL_DFLT_ON
:Thanks for offering to help, and it’s wecome. To be quite honest, just answering questions takes a lot of my and @fubar-coder 's time. I don’t think we get enough development time to actually improve things. So picking off some easy tasks would definitely help towards adding features. I feel this will be a good year roadmap wise, as I have finally come up with some decisions around how to support multiple target framework monikers.