Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum type #85

Open
deba12 opened this issue May 6, 2021 · 2 comments
Open

enum type #85

deba12 opened this issue May 6, 2021 · 2 comments

Comments

@deba12
Copy link

deba12 commented May 6, 2021

Please add enum type in table schema.
From what I have read enum type can be emulated in oracle,sqlite,mssql with check
For mssql

create table sizes (
 size varchar(10) NOT NULL CHECK (name IN('small', 'medium', 'large'))
)

For sqlite

create table sizes (
 size TEXT CHECK( pType IN ('small','medium','large'))
)

For oracle

create table sizes (
 size VARCHAR2(10) CHECK( name IN ('small','medium','large'))
)

For postregres

CREATE TYPE size_enum AS ENUM ('small', 'medium', 'large');
create table sizes (
 size size_enum;
)

And finally mysql

create table sizes (
 size enum('small','medium','large');
)

And php can be something like

$db->schema()->create('size', static function(CreateTable $table) {
  $table->enum('size, ['small', 'medium', 'large']);
});

What do you think?

Cheers,

@sorinsarca
Copy link
Member

I like this idea, but the postgresql examples has two queries.
I think that the below example also works for postgresql

create table sizes (
 size VARCHAR2(10) CHECK( size IN ('small','medium','large'))
)

@deba12
Copy link
Author

deba12 commented May 10, 2021

I am not proficient enough to say will it works.
I can test with sqlite3 and mysql.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants