seeding

Contact form: error on seeding and error messages of the form don't work properly

断了今生、忘了曾经 提交于 2019-12-13 06:49:58
问题 The app I'm building includes a contact form. On seeding it generates an error message that I don't understand: ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: null value in column "name" violates not-null constraint DETAIL: Failing row contains (1, null, null, null, 2015-06-06 13:43:12.339477, 2015-06-06 13:43:12.339477). : INSERT INTO "messages" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" Below is the relevant code for the form. If I remove the line attr

How to seed dependent data in Node/MongoDB

蹲街弑〆低调 提交于 2019-12-12 17:17:58
问题 I am trying to seed a MongoDB database with a one-to-many relationship using objectID's. Something like the following: var postSchema = mongoose.Schema({ name: {type: String, required: true, unique: true}, description: {type: String}, userlikes: [{type: mongoose.Schema.Types.ObjectId, ref: 'Users'}] }); A synchronous implementation of this would look something like this (pseudocode): openConnection() cleardb() users = createUsers() post = createPost(users) Using Node I need to nest each of

ASP.NET Core 2.2 Create IdentityUser

故事扮演 提交于 2019-12-12 13:32:21
问题 Brand new to ASP.Net Core. Having to create an asp.net core 2.2 project with Identity (and have users seeded). I can't find any documentation on how to do this exactly. I was able to find the code to create Identity Roles (compiles anyway, haven't gotten to where I can run it yet: private static async Task CreateUserTypes(ApplicationDbContext authContext, IServiceProvider serviceProvider) { var RoleManager = serviceProvider.GetRequiredService<RoleManager<IdentityRole>>(); string[] roleNames =

Entity Framework - Seed AddOrUpdate with multi column index as identifier

让人想犯罪 __ 提交于 2019-12-12 08:28:52
问题 I am trying to seed a database using the context.AddOrUpdate method, but the problem is that I need to make the inserted data unique based on a multi column index. [Table("climbing_grades")] public class ClimbingGrade : EntityBase { /// <summary> /// The name of the climbing grade, e.g.: 7a, VII, etc. /// </summary> [Index("IX_Name_GradeType", 1, IsUnique = true)] public string Name { get; set; } /// <summary> /// Tries to display the average difficulty of the described grade. /// Matching

Rails db:seed error “undefined method `finder_needs_type_condition?' for nil:NilClass”

落花浮王杯 提交于 2019-12-11 04:26:55
问题 I have a problem when attempting to populate my sqlite db. There's not much info regarding the specific error "finder_needs_type_condition?" that I can find, but I don't have much experience with Rails yet to even suspect where the problem could be. Model: class Character < ActiveRecord::Base validates :user_id, :name, :class, presence: true end Controller: class CharactersController < ApplicationController before_action :authenticate_user! respond_to :json @user_id = current_user[:id] def

Hibernate - Seed database without using import.sql

回眸只為那壹抹淺笑 提交于 2019-12-10 14:22:13
问题 I come from php/laravel. Whenever I want to seed the database i only need to run php artisan db:seed . This will run some php scripts that will insert data into the database. I want to achieve this same feature using spring/hibernate. I know I can add an import.sql file to seed the database after schema creation. However, I want to import these fixtures using java and the ORM available so I do not need to maintain an sql. Is there a way? If not, there should be some configuration to trigger a

Laravel 5.1 foreign keys in model factory

孤街醉人 提交于 2019-12-10 13:10:00
问题 How do you define foreign keys in a model factory. For example if I have a organisations table which has a foreign key to the countries table, in my model factory I'm having to define a dummy value for the country id as follows: $factory->define(App\Organisation::class, function ($faker) { return [ 'name' => $faker->company, 'country_id' => 197, ]; }); In my organisations table seeder class I am doing the following but the faker object isn't present - do I need to create a new faker object in

Rails Seed-Fu Writer why seed got commented out?

蓝咒 提交于 2019-12-07 08:40:31
So, here's my custom rake task: task :backup => :environment do |t| SeedFu::Writer.write('/path/to/file.rb', class_name: 'Category', constraints: [:id] do |w| Category.all.each do |x| w << x end end end And the following result file contains: # DO NOT MODIFY THIS FILE, it was auto-generated. # # Date: 2014-06-15 21:08:13 +0700 # Seeding Category # Written with the command: # # /home/dave/.rvm/gems/ruby-2.1.2/bin/rake backup # Category.seed(:id, #<Category id: 1, name: "foo">, #<Category id: 2, name: "bar">, #<Category id: 3, name: "baz"> ) # End auto-generated file. Question: Why did the

Laravel 5 Reseeding the Database for Unit Testing Between Tests

偶尔善良 提交于 2019-12-07 04:11:49
问题 I start with a seeded database and am trying to reseed the database between unit tests in Laravel 5. In Laravel 4 I understand you could simply use Illuminate\Support\Facades\Artisan and run the commands Artisan::call('migrate'); Artisan::call('db:seed'); or you supposedly could do: $this->seed('DatabaseSeeder'); before every test. In Laravel 5 this appears to have been replaced by use DatabaseMigrations; or use DatabaseTransactions; I have tried using these and have managed to get the tests

Seeding database with path from code?

♀尐吖头ヾ 提交于 2019-12-06 05:35:08
问题 I've been using Laravel's migrations with the path parameter like so: Artisan::call('migrate', array('--path' => 'path/to/my/Migrations')); Is there anyway I can run the seed command in the same way? I have a number of seed files I want to use but I don't want to run them all at the same time. Any advice appreciated. Thanks 回答1: Instead of --path you can set --class with namespace to Seeder class. Artisan::call('db:seed', [ '--class' => 'Namespace\Seeds\DatabaseSeeder' ]); This work on