I have a very simple app that I'm building with Python, SQLAlchemy, PostgreSQL and Turbogears 2.3.
The app works in my local machine, where I use SQLite. However, when I upload it to Heroku, I don't know how to create there the PostgreSQL tables that TurboGears2 uses for authentication and validation: tables like User, Gruoups, Permissions.
I see the schema is defined in a file called auth.py
which looks like this:
....
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Unicode, Integer, DateTime
from sqlalchemy.orm import relation, synonym
from example2.model import DeclarativeBase, metadata, DBSession
class User(DeclarativeBase):
__tablename__ = 'tg_user'
user_id = Column(Integer, autoincrement=True, primary_key=True)
user_name = Column(Unicode(16), unique=True, nullable=False)
email_address = Column(Unicode(255), unique=True, nullable=False)
display_name = Column(Unicode(255))
_password = Column('password', Unicode(128))
created = Column(DateTime, default=datetime.now)
def __repr__(self):
return '<User: name=%s, email=%s, display=%s>' % (
repr(self.user_name), repr(self.email_address), repr(self.display_name))
def __unicode__(self):
return self.display_name or self.user_name
...
So my question is how can I create these tables automatically in the Heroku server? What commmand or script do I have to execute?
Edit: Thanks to JPub's answer, I read on the docs, how to do it from console:
$ gearbox setup-app -c production.ini
And to do it in Heroku it should be:
$ heroku run 'gearbox setup-app -c production.ini'
I dont have any experience with turbogears, but reading through documentation you have two options.
Direct creation:
http://turbogears.readthedocs.org/en/latest/turbogears/gearbox.html#setup-app
Writing your own migrations:
http://turbogears.readthedocs.org/en/latest/turbogears/migrations.html