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

Docs on expected columns #235

Open
OscarGodson opened this issue Nov 18, 2014 · 1 comment
Open

Docs on expected columns #235

OscarGodson opened this issue Nov 18, 2014 · 1 comment

Comments

@OscarGodson
Copy link
Member

I was setting up a SQL database with model and it went fine for the most part, but there was some trial and error since there wasn't (or I might be missing it) docs on what columns are expected and what the types should be. The process for me ended up being something like the following. Each number was on each server restart as I went one by one:

  1. Error: ER_NO_SUCH_TABLE: Table 'test.foos' doesn't exist - Oh create the table, model wont do this like the Mongo one (thats fine)
  2. Error: ER_BAD_FIELD_ERROR: Unknown column 'id' in 'field list' - Oh create an id column (not uuid like I had)
  3. Error: ER_BAD_FIELD_ERROR: Unknown column 'created_at' in 'field list' - Oh, create a created_at column (what format is this going to be in? datetime, timestamp, date...?)
  4. Error: WARN_DATA_TRUNCATED: Data truncated for column 'id' at row 1 - Googles and figures out it happens when an ID is a string not a number on Stackoverflow. Alters table to change it to a VARCHAR(36)
  5. Error: ER_BAD_FIELD_ERROR: Unknown column 'foos.updated_at' in 'field list' - Need to add that too to the table

Now, after those, I think I have everything. But it's not entirely clear. It'd be awesome to have just a general:

When using a SQL adapter your tables will need to be created manually. Each table should have an id, created_at, and updated_at column. The id column stores IDs in the format of UUIDs (so strings) and created_at and updated_at stores data in the format of datetime (YYYY-MM-DD HH:MM:SS)

I can send a PR too, but I wasn't sure if that information is right and is the same for all the SQL DBs.

@mde
Copy link
Contributor

mde commented Nov 19, 2014

Part of this problem comes from the fact that within a Geddy app, you'd be using Migrations to set up all the tables/columns with a nice declarative API. (You could in theory use Migrations outside Geddy, but there's not a documented way to do it.)

Documenting all the datatype mappings would be good. Also good would be setting up a canonical way to use Migrations with Model in isolation, and documenting that.

At this point, an easy workaround would be to create a dummy Geddy app, and use the model generator (geddy gen model) to specify your properties and automatically great a migration you can run to create the table.

Let's start with a PR -- we should definitely have a small table with the mappings of JS datatype to SQL datatypes for each SQL adapter.

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