Migration: Cannot add foreign key constraint

Add it in two steps, and it’s good to make it unsigned too: public function up() { Schema::create(‘priorities’, function($table) { $table->increments(‘id’, true); $table->integer(‘user_id’)->unsigned(); $table->string(‘priority_name’); $table->smallInteger(‘rank’); $table->text(‘class’); $table->timestamps(‘timecreated’); }); Schema::table(‘priorities’, function($table) { $table->foreign(‘user_id’)->references(‘id’)->on(‘users’); }); }

Using Rails, how can I set my primary key to not be an integer-typed column?

Unfortunately, I’ve determined it’s not possible to do it without using execute. Why it doesn’t work By examining the ActiveRecord source, we can find the code for create_table: In schema_statements.rb: def create_table(table_name, options={}) … table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false … end So we can see that when you try to specify a primary … Read more

Version of SQLite used in Android?

Here is a link to the official docs which include the main points in this answer: android.database.sqlite package-level javadoc Kotlin code to get framework SQLite version (tip: just stick a breakpoint in your Activity onCreate() and use this code in Evaluate Expression…): val version = android.database.sqlite.SQLiteDatabase.create(null).use { android.database.DatabaseUtils.stringForQuery(it, “SELECT sqlite_version()”, null) } “Framework (API ${android.os.Build.VERSION.SDK_INT}) … Read more