eoyilmaz/stalker — pull request #18 by fredrikaverpil (2014-08-04 13:00:19+00:00)
Title: MySQL-friendly syntax

In regards to the db.init() issue https://github.com/eoyilmaz/stalker/issues/6

The alembic error was fixed by removing the quotation marks around the table name, and hopefully this fix also works fine with Postgres. Now the current alembic revision is being written to the database successfully. This has never worked here before. This I would consider a proper and safe fix.

I also attempted to remove the error about the foreign key by not giving it a name and remove the `use_alter=True`. Although everything seems to work fine here (creating projects and tasks etc) I'm not sure if I have done something bad here or if it could be considered a good fix. But for some reason giving this foreign key a name creates problems. It could be possible that this foreign key is being set twice for some reason, and that this could in fact be the root cause. However, this fix works fine for me.

Here's the full output of db.init() which now completes without errors (please note I have abandoned MySQL-Python and I am instead using the mysql-connector-python which is written in pure python):

```
DEBUG:stalker.db:no settings given, using the default: {'sqlalchemy.echo': False, 'sqlalchemy.url': 'sqlite:///:memory:'}
DEBUG:stalker.db:settings: {'sqlalchemy.echo': False, 'sqlalchemy.url': 'sqlite:///:memory:'}
DEBUG:stalker.db:engine: Engine(sqlite:///:memory:)
DEBUG:stalker.db:creating the tables
DEBUG:stalker.db:settings: {'sqlalchemy.url': 'mysql+mysqlconnector://***:***@192.168.0.131/stalker'}
DEBUG:stalker.db:engine: Engine(mysql+mysqlconnector://***:***@192.168.0.131/stalker)
DEBUG:stalker.db:creating the tables
DEBUG:stalker.db:initializing database
DEBUG:stalker.db:creating the default administrator user
DEBUG:stalker.models.auth:name out: admin
DEBUG:stalker.db:Creating Ticket Statuses
DEBUG:stalker.db:status_names: ['New', 'Accepted', 'Assigned', 'Reopened', 'Closed']
DEBUG:stalker.db:statuses: []
DEBUG:stalker.db:statuses_names_in_db: []
DEBUG:stalker.db:Creating Status: New (NEW)
DEBUG:stalker.models.mixins:validating code value of: NEW
DEBUG:stalker.db:Creating Status: Accepted (ACP)
DEBUG:stalker.models.mixins:validating code value of: ACP
DEBUG:stalker.db:Creating Status: Assigned (ASG)
DEBUG:stalker.models.mixins:validating code value of: ASG
DEBUG:stalker.db:Creating Status: Reopened (ROP)
DEBUG:stalker.models.mixins:validating code value of: ROP
DEBUG:stalker.db:Creating Status: Closed (CLS)
DEBUG:stalker.models.mixins:validating code value of: CLS
DEBUG:stalker.db:No Ticket Status List found, creating new!
DEBUG:stalker.db:Created Ticket Statuses successfully
DEBUG:stalker.db:Creating Ticket Types
DEBUG:stalker.models.mixins:validating code value of: Defect
DEBUG:stalker.models.mixins:validating code value of: Enhancement
DEBUG:stalker.db:Ticket Types are created successfully
DEBUG:stalker.db:Creating Daily Statuses
DEBUG:stalker.db:status_names: ['Open', 'Closed']
DEBUG:stalker.db:statuses: []
DEBUG:stalker.db:statuses_names_in_db: [u'Closed']
DEBUG:stalker.db:Creating Status: Open (OPEN)
DEBUG:stalker.models.mixins:validating code value of: OPEN
DEBUG:stalker.db:Status Closed (CLS) is already created skipping!
DEBUG:stalker.db:No Daily Status List found, creating new!
DEBUG:stalker.db:Created Daily Statuses successfully
DEBUG:stalker.db:Creating Task Statuses
DEBUG:stalker.db:status_names: ['Waiting For Dependency', 'Ready To Start', 'Work In Progress', 'Pending Review', 'Has Revision', 'Dependency Has Revision', 'On Hold', 'Stopped', 'Completed']
DEBUG:stalker.db:statuses: []
DEBUG:stalker.db:statuses_names_in_db: []
DEBUG:stalker.db:Creating Status: Waiting For Dependency (WFD)
DEBUG:stalker.models.mixins:validating code value of: WFD
DEBUG:stalker.db:Creating Status: Ready To Start (RTS)
DEBUG:stalker.models.mixins:validating code value of: RTS
DEBUG:stalker.db:Creating Status: Work In Progress (WIP)
DEBUG:stalker.models.mixins:validating code value of: WIP
DEBUG:stalker.db:Creating Status: Pending Review (PREV)
DEBUG:stalker.models.mixins:validating code value of: PREV
DEBUG:stalker.db:Creating Status: Has Revision (HREV)
DEBUG:stalker.models.mixins:validating code value of: HREV
DEBUG:stalker.db:Creating Status: Dependency Has Revision (DREV)
DEBUG:stalker.models.mixins:validating code value of: DREV
DEBUG:stalker.db:Creating Status: On Hold (OH)
DEBUG:stalker.models.mixins:validating code value of: OH
DEBUG:stalker.db:Creating Status: Stopped (STOP)
DEBUG:stalker.models.mixins:validating code value of: STOP
DEBUG:stalker.db:Creating Status: Completed (CMPL)
DEBUG:stalker.models.mixins:validating code value of: CMPL
DEBUG:stalker.db:No Task Status List found, creating new!
DEBUG:stalker.db:Created Task Statuses successfully
DEBUG:stalker.db:Creating Asset Statuses
DEBUG:stalker.db:status_names: ['Waiting For Dependency', 'Ready To Start', 'Work In Progress', 'Pending Review', 'Has Revision', 'Dependency Has Revision', 'On Hold', 'Stopped', 'Completed']
DEBUG:stalker.db:statuses: [, , , , , , , , ]
DEBUG:stalker.db:statuses_names_in_db: [u'Waiting For Dependency', u'Ready To Start', u'Work In Progress', u'Pending Review', u'Has Revision', u'Dependency Has Revision', u'On Hold', u'Stopped', u'Completed']
DEBUG:stalker.db:Status Waiting For Dependency (WFD) is already created skipping!
DEBUG:stalker.db:Status Ready To Start (RTS) is already created skipping!
DEBUG:stalker.db:Status Work In Progress (WIP) is already created skipping!
DEBUG:stalker.db:Status Pending Review (PREV) is already created skipping!
DEBUG:stalker.db:Status Has Revision (HREV) is already created skipping!
DEBUG:stalker.db:Status Dependency Has Revision (DREV) is already created skipping!
DEBUG:stalker.db:Status On Hold (OH) is already created skipping!
DEBUG:stalker.db:Status Stopped (STOP) is already created skipping!
DEBUG:stalker.db:Status Completed (CMPL) is already created skipping!
DEBUG:stalker.db:No Asset Status List found, creating new!
DEBUG:stalker.db:Created Asset Statuses successfully
DEBUG:stalker.db:Creating Shot Statuses
DEBUG:stalker.db:status_names: ['Waiting For Dependency', 'Ready To Start', 'Work In Progress', 'Pending Review', 'Has Revision', 'Dependency Has Revision', 'On Hold', 'Stopped', 'Completed']
DEBUG:stalker.db:statuses: [, , , , , , , , ]
DEBUG:stalker.db:statuses_names_in_db: [u'Waiting For Dependency', u'Ready To Start', u'Work In Progress', u'Pending Review', u'Has Revision', u'Dependency Has Revision', u'On Hold', u'Stopped', u'Completed']
DEBUG:stalker.db:Status Waiting For Dependency (WFD) is already created skipping!
DEBUG:stalker.db:Status Ready To Start (RTS) is already created skipping!
DEBUG:stalker.db:Status Work In Progress (WIP) is already created skipping!
DEBUG:stalker.db:Status Pending Review (PREV) is already created skipping!
DEBUG:stalker.db:Status Has Revision (HREV) is already created skipping!
DEBUG:stalker.db:Status Dependency Has Revision (DREV) is already created skipping!
DEBUG:stalker.db:Status On Hold (OH) is already created skipping!
DEBUG:stalker.db:Status Stopped (STOP) is already created skipping!
DEBUG:stalker.db:Status Completed (CMPL) is already created skipping!
DEBUG:stalker.db:No Shot Status List found, creating new!
DEBUG:stalker.db:Created Shot Statuses successfully
DEBUG:stalker.db:Creating Sequence Statuses
DEBUG:stalker.db:status_names: ['Waiting For Dependency', 'Ready To Start', 'Work In Progress', 'Pending Review', 'Has Revision', 'Dependency Has Revision', 'On Hold', 'Stopped', 'Completed']
DEBUG:stalker.db:statuses: [, , , , , , , , ]
DEBUG:stalker.db:statuses_names_in_db: [u'Waiting For Dependency', u'Ready To Start', u'Work In Progress', u'Pending Review', u'Has Revision', u'Dependency Has Revision', u'On Hold', u'Stopped', u'Completed']
DEBUG:stalker.db:Status Waiting For Dependency (WFD) is already created skipping!
DEBUG:stalker.db:Status Ready To Start (RTS) is already created skipping!
DEBUG:stalker.db:Status Work In Progress (WIP) is already created skipping!
DEBUG:stalker.db:Status Pending Review (PREV) is already created skipping!
DEBUG:stalker.db:Status Has Revision (HREV) is already created skipping!
DEBUG:stalker.db:Status Dependency Has Revision (DREV) is already created skipping!
DEBUG:stalker.db:Status On Hold (OH) is already created skipping!
DEBUG:stalker.db:Status Stopped (STOP) is already created skipping!
DEBUG:stalker.db:Status Completed (CMPL) is already created skipping!
DEBUG:stalker.db:No Sequence Status List found, creating new!
DEBUG:stalker.db:Created Sequence Statuses successfully
DEBUG:stalker.db:Creating Review Statuses
DEBUG:stalker.db:status_names: ['New', 'Requested Revision', 'Approved']
DEBUG:stalker.db:statuses: []
DEBUG:stalker.db:statuses_names_in_db: [u'New']
DEBUG:stalker.db:Status New (NEW) is already created skipping!
DEBUG:stalker.db:Creating Status: Requested Revision (RREV)
DEBUG:stalker.models.mixins:validating code value of: RREV
DEBUG:stalker.db:Creating Status: Approved (APP)
DEBUG:stalker.models.mixins:validating code value of: APP
DEBUG:stalker.db:No Review Status List found, creating new!
DEBUG:stalker.db:Created Review Statuses successfully
DEBUG:stalker.db:creating alembic_version table
DEBUG:stalker.db:inserting 2e4a3813ae76 to alembic_version table
DEBUG:stalker.db:alembic_version table is created and initialized
DEBUG:stalker.db:finished initializing the database
```