我正在将PyCharm 2018.2与Python 3.7一起使用。我已经在settings.py文件中定义了数据库...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mainsite',
'USER': 'mainsite',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432'
}
}
在Mac上使用“ Option + R”,我可以打开“ manage.py”控制台,并在其中运行迁移。我通过运行以下命令来做到这一点。看来成功了...
manage.py@mainsite_project > sqlmigrate mainsite 0002
bash -cl "/Users/davea/Documents/workspace/mainsite_project/venv/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py sqlmigrate mainsite 0002 /Users/davea/Documents/workspace/mainsite_project"
Tracking file by folder pattern: migrations
/Users/davea/Documents/workspace/mainsite_project/venv/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
BEGIN;
--
-- Add field url to article
--
ALTER TABLE "mainsite_article" ADD COLUMN "url" text DEFAULT '' NOT NULL;
ALTER TABLE "mainsite_article" ALTER COLUMN "url" DROP DEFAULT;
COMMIT;
Process finished with exit code 0
但是,当我在本地查看数据库时,我看不到那里的额外列...
mainsite=> \d mainsite_article;
Table "public.mainsite_article"
Column | Type | Modifiers
--------------+--------------------------+----------------------------------------------------------------
id | integer | not null default nextval('mainsite_article_id_seq'::regclass)
path | character varying(100) | not null
time | timestamp with time zone | not null
votes | integer | not null
comments | integer | not null
main_page | boolean | not null
Indexes:
"mainsite_article_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "mainsite_mainsitestat" CONSTRAINT
我在做什么错了?