How can I fix Postgres errors in Minitest?

I am using Minitest and Postgres to test my Rails website. When I added a “Like” model, I started getting Postgresql deadlock errors

Minitest::UnexpectedError: ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR:  deadlock detected LINE 7: DELETE FROM "videos";                     ^ DETAIL:  Process 11456 waits for RowExclusiveLock on relation 42608 of database 42434; blocked by process 10460. Process 10460 waits for ShareRowExclusiveLock on relation 42564 of database 42434; blocked by process 11456. HINT:  See server log for query details. 

Other errors:

Minitest::UnexpectedError: ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "accounts_pkey"
DETAIL:  Key (id)=(825136781) already exists.
Minitest::UnexpectedError: ActiveRecord::ConnectionNotEstablished: connection is closed

My models:

class Like < ApplicationRecord
  belongs_to :profile
  belongs_to :video
end
class Video < ApplicationRecord
  belongs_to :profile
  has_one_attached :source

  has_and_belongs_to_many :likes_profiles, class_name: 'Profile', join_table: 'likes'

#Some validations...
end
class Profile < ApplicationRecord
  belongs_to :account

  has_many :followers_follow, foreign_key: :followee_id, class_name: 'Follow', dependent: :destroy
  has_many :followers, through: :followers_follow, source: :follower, dependent: :destroy
  has_many :followees_follow, foreign_key: :follower_id, class_name: 'Follow', dependent: :destroy
  has_many :followees, through: :followees_follow, source: :followee, dependent: :destroy
  has_many :videos, dependent: :destroy

  has_and_belongs_to_many :liked_videos, class_name: 'Video', join_table: 'likes'

  has_one_attached :avatar
# Some validations...
end

Like model tests:

require "test_helper"

class LikeTest < ActiveSupport::TestCase
  def setup
    @profile1 = profiles(:basic1)
    @profile2 = profiles(:basic2)
    @video1 = videos(:one)
  end

  test 'profile should be able to like video' do
    f = Like.new(profile_id: @profile2.id, video_id: @video1.id)
    assert f.save
    assert @profile2.liked_videos.include?(@video1)
    assert @video1.likes_profiles.include?(@profile2)
  end

  test 'should not like second time' do
    f = Like.new(profile_id: @profile1.id, video_id: @video1.id)
    assert_not f.save
  end
end

Everything was good until I added Like model

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật