使用PostgresSQL和Django,我手动从postgresql中删除了两个表。然后我做了make migrations和migrate。但是我的表不会被重新创建。无法从shell_plus访问。同样在此页面中,django返回relation 'table name' does not exists. 我想进行迁移,然后再次创建表格。 我如何解决我的问题?
我在本地env中的postgres中创建了一个“活动”表。我从来没有做过改变,因此也没有把它推向heroku的生产。
当我改变主意需要那个表时,我愚蠢地手动删除了迁移(我现在知道永远不会这么做)。但是,由于迁移已经运行,我创建了一个21041211003219_drop_campaigns_table迁移以从本地db删除表。
现在,当我在生产上运行heroku run rake db:migrate时,会得到以下错误:
Migrating to DropCampaignsTable (20141211003219)
我正在尝试用postgres建立一个简单的web应用程序。在我运行应用程序之后(还没有数据库相关的代码)。
我在app中添加了一个postgres插件,命令heroku addons:create heroku-postgresql:hobby-dev --app <app_name>
Ran heroku psql heroku pg:psql --app.
尝试从提示符:CREATE TABLE example_table ( a INTEGER );创建表
我看到了错误:
ERROR: no schema has been selected to creat
我有一个在Heroku上直播的Django项目。
我试图在remote上创建一个超级用户,但是我得到了:django.db.utils.OperationalError: no such table: auth_user
因此,我运行heroku run python manage.py migrate并获得预期的响应。
Running python manage.py migrate on ⬢ MyWebsite... up, run.5296 (Free)
Operations to perform:
Apply all migrations: admin, auth, authtok
首先,我运行:rails generate model User name:string email:string和this创建一个迁移。后来我做了一个db:migrate,我得到了这个错误:
bundle exec rake db:migrate
== 20150728195629 CreateUsers: migrating ======================================
-- create_table(:users)
rake aborted!
StandardError: An error has occurred, this and all later
我遵循了Djangogirls教程,通常该教程要求您在pythonanywhere上创建一个数据库。在使用sqlite3时,这通常没有问题,但是这次我使用的是postgresql,当我在控制台中运行migrate命令时,我得到了以下错误:
conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: could not connect to server: No such file or directory
I
我正在尝试使用peewee的迁移模块将列从name重命名为title,在我的page表中。然而,我正在运行这个令人困惑的错误:
peewee.OperationalError: table page__tmp__ has no column named FOREIGN
我的猜测是,它与创建中间表的需要有关,当使用sqlite时。
电流模型:
完整的源代码在这里
class User(BaseModel):
id = peewee.CharField(primary_key=True, max_length=20)
class Page(BaseModel):
id = pe
我在我的应用程序events中创建了以下模型:
from django.db import models
from django.utils import timezone
from django.urls import reverse
class EventType(models.Model):
type_of_event = models.CharField(max_length=100, unique=True)
def __str__(self):
return self.type_of_event
class Event(models.Mod
根据,我做了"heroku addons:add heroku-postgresql:dev“。但当我这么做的时候
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
execute "CREATE EXTENSION hstore"
t.hstore :access
end
end
def down
drop_table :users
execute "DROP
我在PostgreSQL方面很新,只知道数据库的基本操作。我有一个名为neuro_db的数据库,它的用户名是neuro_user。现在,我发现无法从neuro_db中删除表中的列。
在Ubuntu14.04中尝试了psql neuro_db之后,我进入了一个从neuro_db=#开始的命令行。\d命令将显示如下表:
List of relations
Schema | Name | Type | Owner
--------+------------------------
我有一个rails模型List。
我在终端中输入了rails d model list,结果如下:
invoke active_record
remove db/migrate/20140116161958_create__lists.rb
remove app/models/list.rb
invoke rspec
remove spec/models/list_spec.rb
然后我输入了rails g model list name:string size:integer,它给了我这个:
invoke active_record
我有一个烧瓶应用程序,连接到一个PostgreSQL数据库。我集成了芹菜,并将其结果后端配置为相同的postgresql数据库。
在烧瓶应用程序中使用的其他表在代码中有类定义,并使用alembic (烧瓶-迁移)生成:
$ flask db migrate -m "add a table" (creates migration file)
$ flask db upgrade (applies changes in migration file to the db)
问题
我在代码中为表添加了一个新类,并运行了flask db migrate -m "add test
我正在开发一个带有Django和PostgreSQL支持的web应用程序。我正在使用Psycopg2连接我的PostgreSQL数据库。我试图在我的Home.html文档中列出我的数据库中的所有表。
我在Home.html文档中显示这一点有困难。下面我包含了我的代码。
models.py
from django.db import models
import psycopg2
# Create your models here.def __init__(self, db='giquery-data'):
class Tables(models.Model):
co
我在PostgreSQL 16中有IMDB数据库,还有表title_basics。该表包含几个列,包括titleSearchCol,它的类型为tsvector。当我试图使用psql删除列时,
ALTER TABLE title_basics DROP COLUMN titleSearchCol;
PostgreSQL抛出一个错误
ERROR: column "titlesearchcol" of relation "title_basics" does not exist
我可以查询该表,添加更多的列,并使用相同的语法删除其他列。我也尝试过postgres超级