database-migration

Determining the range of value for a field in database by using db-migration

点点圈 提交于 2019-12-04 06:13:55
问题 I've used Entity Framework 6.x and I've produced my database by code-first approach. After creating db, I've decided to some changes in my db. for example I want to determine a range of value for Size property in my model. my model: public class Tag : Entity, ITag { /// <summary> /// Size can be 1, 2, 3 or 4 /// </summary> [Range(1, 4)] public virtual int Size { get; set; } [Required] [StringLength(25)] public virtual string Title { get; set; } [StringLength(256)] public virtual string

Is it considered safe to manually edit schema.rb in rails

时光总嘲笑我的痴心妄想 提交于 2019-12-04 05:29:06
I came across a problem where I was working on two branches on a rails project and each project has a migration to add a column. At the time, rake db:migrate:reset cause a problem and I solely relied on my schema.rb to correctly represent the state of my database. At one point, I came across a problem where a column added by branch A got into the schema of branch B. Since migrate:reset was not an option, I resorted to manually editing the schema file to. I committed this change that basically deleted the column from branch A that I did not need in branch B's schema.rb. Problem came after I

How to avoid data loss with EF Model First database schema upgrade?

二次信任 提交于 2019-12-04 04:54:30
This is a long question, but I would be very very thankful if I can get some good advice on this. In short, I’m looking for a good approach for version upgrade of MS SQL database schema that also demands data being moved from deleted tables into new tables. I think Stack Overflow is the most appropriate place for this question (not dba.stackexchange.com) because at its core, this is an issue for .NET developers using Entity Framework, and the database parts of this consists mostly of auto-generated sql scripts. Background A .NET application and SQL database is running in Azure (The application

PDOException (1044) SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'

微笑、不失礼 提交于 2019-12-04 04:29:35
问题 I am using Laravel 5 and getting the following exception: PDOException (1044) SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' My database configuration file is: <?php return [ /* |-------------------------------------------------------------------------- | PDO Fetch Style |-------------------------------------------------------------------------- | | By default, database results will be returned as instances of the PHP | stdClass object; however, you may

Migrating `int` to `bigint` in PostgresSQL without any downtime?

[亡魂溺海] 提交于 2019-12-04 03:47:50
问题 I have a database that is going to experience the integer exhaustion problem that Basecamp famously faced back in November. I have several months to figure out what to do. Is there a no-downtime-required, proactive solution to migrating this column type? If so what is it? If not, is it just a matter of eating the downtime and migrating the column when I can? Is this article sufficient, assuming I have several days/weeks to perform the migration now before I'm forced to do it when I run out of

Django 1.7 Migrations hanging

删除回忆录丶 提交于 2019-12-04 03:31:34
I have a django migration I am trying to apply. It gets made fine (it's small, it's only adding a CharField to two different Models. However when I run the actual migrate it hangs (no failure, no success, just sits). Through googling I've found that other open connections can mess with it so I restarted the DB. However this DB is connect to continuously running jobs and new queries do sneak in right away. However they are small, and last time I tried restarting I THINK I was able to execute my migrate before anything else. Still nothing. Are there any other known issues that cause something

Laravel Migration - Adding Check Constraints In Table

﹥>﹥吖頭↗ 提交于 2019-12-04 03:00:02
I want to create a table in Laravel Migration like this- CREATE TABLE Payroll ( ID int PRIMARY KEY, PositionID INT, Salary decimal(9,2) CHECK (Salary < 150000.00) ); What I have done is- Schema::create('Payroll', function (Blueprint $table) { $table->increments('id'); $table->integer('PositionID '); $table->decimal('Salary',9,2); //$table->timestamps(); }); But I can't create this- CHECK (Salary < 150000.00) Can anyone please tell, how to implement this CHECK constraints in Laravel Migration ? Adding constraints is not supported by the Blueprint class (at least as of Laravel 5.3), however it

Flyway 5.0.7 warning about using schema_version table

半城伤御伤魂 提交于 2019-12-04 02:50:25
问题 We use the Flyway Gradle plugin to do our migrations offline (i.e. we migrate while the system is down). We recently upgraded to Flyway 5.0.7 and we see this warning now for migrations: Could not find schema history table XXXXXXX . flyway_schema_history , but found XXXXXXX . schema_version instead. You are seeing this message because Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway

Adding fields to an already existing database for Django (version < 1.7)

亡梦爱人 提交于 2019-12-04 02:23:32
I'm using Django ( < v1.7), with SQLite3 as the database engine. I am trying to add a new field to an already existing model's class. This class already has data associated to it. manage.py syncdb is not adding the new fields to the db. Is there was a way to: Add the new Field to the already existing class, and make sure a db entry is allocated to it? Populate this new field with an empty string for all the already existing db entries? Install south in your django and you can easily handle the existing tables. check this If you really want to use Django-South, install it on your django, after

How to migrate MySQL data directory in docker container?

谁都会走 提交于 2019-12-04 02:22:30
I have a docker container running MySQL-5.5 with host data volume. I am upgrading my container to MySQL-5.6. I am starting a new container with the same host volume. MySQL was crashing in the container due to the crash of mysql.user table. [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect key file for table 'user'; try to repair it 160523 12:04:13 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended I tried the following to fix that: root@container# mysqld --skip-grant-tables; root@container# mysql -uroot -ppassword mysql> repair table user USE_FRM; +-----------