fizz icon indicating copy to clipboard operation
fizz copied to clipboard

Unsigned integer

Open fnaysee opened this issue 6 years ago • 3 comments

Hi, How can i create an unsigned integer field with fizz?

fnaysee avatar Mar 29 '19 14:03 fnaysee

You can use the name your database engine calls it, if it supports it. If the type you specify isn't one of the "common types", it will just be passed unaltered back to the database. README.md#common-types

It appears PostgreSQL doesn't support unsigned integers at all. https://stackoverflow.com/questions/20810134/why-unsigned-integer-is-not-available-in-postgresql

duckbrain avatar Apr 29 '19 22:04 duckbrain

Unsigned integers aren't a separate type, it is an attribute that can be applied to most numeric types in MySQL. For now here is what I am using:

create_table("users") {
	t.Column("id", "integer", {primary: true})
	t.Column("email", "string", {})
	t.Column("password", "string", {})
	t.Column("admin", "bool", {"default": false, })
	t.Timestamps()
	t.Column("deleted_at", "timestamp", {"null": true})
}
add_index("users", "admin", {})
sql("ALTER TABLE `users` CHANGE `id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT")

pitchinnate avatar Mar 19 '21 19:03 pitchinnate

The solution for this request could be the same as the second option of https://github.com/gobuffalo/fizz/issues/13#issuecomment-1243624577, which is supporting a custom option.

sio4 avatar Sep 15 '22 11:09 sio4