Start in the development of a small project to learn Ruby on Rails, I started with a small tutorial in which I do a Resources to insert data to the BD through a form, the point is that I get the following error :
ActiveRecord::StatementInvalid: SQLite3::CorruptException: malformed database schema () - near "(": syntax error: SELECT name FROM sqlite_master WHERE name <> 'sqlite_sequence' AND name = 'schema_migrations' AND type IN ('table')
Caused by:
SQLite3::CorruptException: malformed database schema () - near "(": syntax error
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Apparently this is associated with SQLite, and the conflict as I understand it refers to an SQL query that was generated automatically by the framework, the file of my table located in the db / migrate folder is:
class CreateArticles < ActiveRecord::Migration[5.1]
def change
create_table :articles do |t|
t.string :title
t.text :text
t.timestamps
end
end
end
My model for article is:
class Article < ApplicationRecord
end
My controller is:
class ArticlesController < ApplicationController
def new
end
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
private
def article_params
params.require(:article).permit(:title, :text)
end
def show
@article = Article.find(params[:id])
end
end
And my view is:
<%= form_for :article, url: articles_path do |f| %>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
When executing rails db: migrate appears:
rails aborted!
ActiveRecord::StatementInvalid: SQLite3::CorruptException: malformed database schema () - near "(": syntax error: SELECT name FROM sqlite_master WHERE name <> 'sqlite_sequence' AND name = 'schema_migrations' AND type IN ('table')
bin/rails:4:in 'require'
bin/rails:4:in '<main>'
Caused by:
SQLite3::CorruptException: malformed database schema () - near "(": syntax error
bin/rails:4:in 'require'
bin/rails:4:in '<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The table article responds to the following SQL:
DROP TABLE IF EXISTS articles;
CREATE TABLE articles (
id INTEGER PRIMARY KEY AUTOINCREMENT
NOT NULL,
title VARCHAR,
text TEXT,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL
);
Some help I would appreciate it Greetings