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

Execute DDL - Ecto.Adapters.SQL.Connection #44

Open
Danwhy opened this issue Feb 14, 2019 · 3 comments
Open

Execute DDL - Ecto.Adapters.SQL.Connection #44

Danwhy opened this issue Feb 14, 2019 · 3 comments
Assignees
Labels
discuss enhancement New feature or request question Further information is requested T1d

Comments

@Danwhy
Copy link
Member

Danwhy commented Feb 14, 2019

Part of #38

https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Connection.html#c:execute_ddl/1

This is the function we use to run migrations. The existing implementation of this has multiple function clauses, so it's likely that we can use some of them, and override others.

It's here that we can ensure certain columns are added to tables when they're created, as well as defining the cid as the primary key.

@Danwhy Danwhy added the enhancement New feature or request label Feb 14, 2019
@Danwhy Danwhy self-assigned this Feb 15, 2019
@Danwhy
Copy link
Member Author

Danwhy commented Feb 18, 2019

When creating a table, we can add the cid primary key to the columns to create, then forward the modified request on to the Postgres adapter.

But what do we want to do if the user has already specified a primary key in their creation table. Do we raise an error, or do we create a composite primary key, which is the default when multiple columns are marked as the pk?

@Danwhy Danwhy added question Further information is requested discuss labels Feb 18, 2019
@SimonLab
Copy link
Member

Raising an error might be a good first step if a primary key is defined by the user. As you mention on the standup we can later on if necessary create a new primary key by combining the cid and the primary key created by the user.

@Danwhy
Copy link
Member Author

Danwhy commented Feb 20, 2019

The only thing left to do for this function is to add a unique index for cid when a table is created (see #45 (comment)).

Not sure exactly the best way to go about that yet, need to look into it a bit more.

@Danwhy Danwhy mentioned this issue Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss enhancement New feature or request question Further information is requested T1d
Projects
None yet
Development

No branches or pull requests

4 participants