database-migration

Laravel running migrations on “app/database/migrations” folder recursively

99封情书 提交于 2019-11-30 04:54:49
So my migrations folder looks like this since I have dozens of tables it keeps things organized and clean: migrations/ create_user_table.php relations/ translations/ I'm trying to do a refresh all migrations and seed but it seems like I've run into a slight hiccup where I don't know the artisan command to run migrations recursively (i.e. run migrations in the relations and translations folders as well). I've tried adding --path="app/database/migrations/*" however it spat out an error. Does anyone know the solution to this? automaticAllDramatic The only way to do it right now is to manually go

Error while upgrading Mongodb from 3.2 to 3.6

倖福魔咒の 提交于 2019-11-30 03:15:10
I needed to upgrade mongodb from 3.2 to 3.6 in my environment. For the process i first migrated from 3.2 to 3.4 as recommended. After successful migration to 3.4, i started migration to 3.6 i am not able to start mongod. When checked log file i found error like: IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details. MY Mongod.conf systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log storage: dbPath: /var/lib/mongo journal: enabled:

Postgres on Rails FATAL: database does not exist

橙三吉。 提交于 2019-11-30 02:56:44
I've reinstalled Postgres (9.2.4) and I'm having trouble getting it set back up with Rails 3.2.11. I did: brew install postgresql initdb /usr/local/var/postgres pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start So now I have $ psql --version psql (PostgreSQL) 9.2.4 $ which psql /usr/local/bin/psql My database.yml file looks like development: adapter: postgresql encoding: unicode database: myapp_development pool: 5 username: Tyler password: host: localhost port: 5432 And when I run rake db:create:all then rake db:migrate I get the error: PG::Error: ERROR: relation

Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys

与世无争的帅哥 提交于 2019-11-30 01:26:40
I'm trying to use composite primary key on 2 objects with parent-child relationship. Whenever I try to create a new migration, I get an error: Unable to determine composite primary key ordering for type 'Models.UserProjectRole'. Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys. As per error suggests, I do add annotation Column (Order = X) but the error still there and does not go away, unless I leave only one field with Key annotation. Here is my object that it trips off: public class UserProjectRole { [Key, Column(Order = 0),DatabaseGenerated

How do I add a check constraint in a Rails migration?

≯℡__Kan透↙ 提交于 2019-11-29 23:56:08
I need to add a new integer column to an existing table in my Rails app. The column can only have values 1, 2, 3, so I'd like to add a check constraint to the table/column. How do I specify this constraint within a Rails migration? Rails migration does not provide any way to add Constraints, but you can still do it via migration but by passing actual SQL to execute() Create Migration file: ruby script/generate Migration AddConstraint Now, in the migration file: class AddConstraint < ActiveRecord::Migration def self.up execute "ALTER TABLE table_name ADD CONSTRAINT check_constraint_name CHECK

Rails migration does not change schema.rb

荒凉一梦 提交于 2019-11-29 23:03:10
I have a rails migration that is not being applied to my schema.rb. The migration should create a table: class CreateUserGraphs < ActiveRecord::Migration def change create_table :user_graphs do |t| t.string :name t.string :content t.integer :user_id t.string :type_id t.integer :upload_id t.timestamps end add_index :user_graphs, [:user_id, :created_at] end end I did db:reset. Then I tried rake db:migrate:up VERSION=123123123(this is the migration #). I am in my "dev" environment. Why is the migration not affecting schema.rb? From the documentation : The rake db:reset task will drop the database

Make column not nullable in a Laravel migration

半腔热情 提交于 2019-11-29 20:54:42
I'm writing a migration to make certain columns in a table nullable right now. For the down function, I of course want to make those columns not nullable again. I looked through the schema builder docs , but couldn't see a way to do this. Any help would be appreciated. TLGreg Prior to Laravel 5 there was no Laravel native way of altering an existing table column using the schema builder. You'd need to use raw queries for this. However, as of Laravel 5 you can use: $table->...->nullable(false)->change(); As of Laravel 5, it's possible to reverse this natively - simply pass false as an argument

How to change schema of all tables, views and stored procedures in MSSQL

↘锁芯ラ 提交于 2019-11-29 20:28:12
Recently we were having issues on our database server and after long efforts it was decided to change the database server. So we managed to restore the database on another server, change the connection string, etc. Everything was going as planned until we tried to access the website from a web browser. We started getting errors about database objects not being found. Later we found out that it occured as a result of the modified schema name. Since there are hundreds of database objects (tables, views and stored procedures) in a Kentico database, it is not feasible to change all of them

Ruby on Rails: How can I revert a migration with rake db:migrate?

廉价感情. 提交于 2019-11-29 19:04:23
After installing devise MODEL User i got this. class DeviseCreateUsers < ActiveRecord::Migration def self.up create_table(:users) do |t| t.database_authenticatable :null => false t.recoverable t.rememberable t.trackable # t.encryptable # t.confirmable # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both # t.token_authenticatable t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true # add_index :users, :confirmation_token, :unique => true # add_index :users, :unlock_token, :unique => true # add_index :users,

Using EF4 migration tool with model-first approach

馋奶兔 提交于 2019-11-29 18:18:35
问题 EF migration utility seems quite nice when using code first. Based on this blog post, I tried setting it in my project where we use model-first. When running Enable-Migrations command, I get the following error: Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel. Is there any way around it so we can use the EF